Java URL Connection getRequestHeaders(URLConnection conn)

Here you can find the source of getRequestHeaders(URLConnection conn)

Description

get Request Headers

License

Open Source License

Declaration

public static String getRequestHeaders(URLConnection conn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.*;

public class Main {
    public static String getRequestHeaders(URLConnection conn) {
        StringBuffer headers = new StringBuffer();
        String key;/*from   ww  w  .j av a  2 s.  c o m*/
        int n = 1;

        headers.append("\n----------\n");
        while ((key = conn.getHeaderFieldKey(n)) != null) {
            String value = conn.getHeaderField(n);
            headers.append(key + ": " + value + "\n");
            n++;
        }

        headers.append("----------\n");
        return headers.toString();
    }
}

Related

  1. getPage(String url)
  2. getPageContent(String inputUrlString)
  3. getRealURL(URL url)
  4. getRemoteTimestamp(final String url)
  5. getRequest(URLConnection conn)
  6. getResultsWithEncoding(URLConnection source, String encoding)
  7. getStream(URL url)
  8. getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli)
  9. getString(URL url)