List of utility methods to do HTTP Header
void | printHeaderFields(final URL url) print Header Fields URLConnection conn = null; try { conn = openConnection(url); for (final String name : conn.getHeaderFields().keySet()) { System.out.println(name + "\t" + conn.getHeaderField(name)); } catch (Exception e) { e.printStackTrace(); ... |
void | printHttpURLConnectionHeaders(HttpURLConnection httpURLConnection) print Http URL Connection Headers Map<String, List<String>> s = httpURLConnection.getHeaderFields(); Set<Map.Entry<String, List<String>>> set = s.entrySet(); for (Map.Entry<String, List<String>> ss : set) { System.out.println("key: " + ss.getKey() + " value: " + ss.getValue()); |
Map | readHeadersFromResponse(HttpURLConnection httpURLConnection) read Headers From Response Iterator<String> iterator = httpURLConnection.getHeaderFields().keySet().iterator(); Map<String, String> responseHeaders = new HashMap(); while (iterator.hasNext()) { String key = iterator.next(); if (key != null) { responseHeaders.put(key, httpURLConnection.getHeaderField(key)); return responseHeaders; |
void | setHeader(final HttpURLConnection couchdbConnection, final String headerName, final String headerValue) set Header couchdbConnection.setRequestProperty(headerName, headerValue); |
void | setHeader(HttpURLConnection con, Map headers) set Header Iterator iter = headers.keySet().iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
con.setRequestProperty(key, (String) headers.get(key));
|
void | setHeader(HttpURLConnection urlConnection, String key, String value) set Header urlConnection.setRequestProperty(key, value); |
void | setHeaders(HttpURLConnection conn, List set Headers if (null != headers) { for (Iterator<String> iter = headers.iterator(); iter.hasNext();) { conn.addRequestProperty(iter.next(), iter.next()); conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding); |
void | setHeadersToRequest(HttpURLConnection urlConnection, Map set Headers To Request if (headersMap != null && headersMap.size() > 0) { Iterator<String> iterator = headersMap.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); urlConnection.setRequestProperty(key, headersMap.get(key)); |
String | submitHttpRequest(String url, Map Utility method used to submit an HTTP request. StringBuilder result = new StringBuilder(); HttpURLConnection connection = null; try { connection = (HttpURLConnection) (new URL(url)).openConnection(); connection.setUseCaches(false); connection.setDoInput(true); for (String key : headers.keySet()) { connection.setRequestProperty(key, headers.get(key)); ... |