Here you can find the source of getRequestHeaders(URLConnection conn)
public static String getRequestHeaders(URLConnection conn)
//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(); } }