Java HTTP Header setHeaders(HttpURLConnection conn, List headers, String encoding)

Here you can find the source of setHeaders(HttpURLConnection conn, List headers, String encoding)

Description

set Headers

License

Apache License

Declaration

private static void setHeaders(HttpURLConnection conn, List<String> headers, String encoding) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.HttpURLConnection;

import java.util.Iterator;
import java.util.List;

public class Main {
    private static void setHeaders(HttpURLConnection conn, List<String> headers, String encoding) {
        if (null != headers) {
            for (Iterator<String> iter = headers.iterator(); iter.hasNext();) {
                conn.addRequestProperty(iter.next(), iter.next());
            }// w  w w  .  ja  va  2  s.co m
        }
        conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding);
    }
}

Related

  1. printHttpURLConnectionHeaders(HttpURLConnection httpURLConnection)
  2. readHeadersFromResponse(HttpURLConnection httpURLConnection)
  3. setHeader(final HttpURLConnection couchdbConnection, final String headerName, final String headerValue)
  4. setHeader(HttpURLConnection con, Map headers)
  5. setHeader(HttpURLConnection urlConnection, String key, String value)
  6. setHeadersToRequest(HttpURLConnection urlConnection, Map headersMap)
  7. submitHttpRequest(String url, Map headers, String data)