Here you can find the source of getResponseHeaders(URLConnection conn, HashMap
Parameter | Description |
---|---|
conn | a parameter |
headers | a parameter |
public static String getResponseHeaders(URLConnection conn, HashMap<String, String> headers)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.net.URLConnection; import java.util.HashMap; public class Main { /**//from w w w.ja va 2s . co m * Gets the headers * * @param conn * @param headers * @return 1st response line */ public static String getResponseHeaders(URLConnection conn, HashMap<String, String> headers) { headers.clear(); String responseCode = ""; for (int i = 0;; i++) { String name = conn.getHeaderFieldKey(i); String value = conn.getHeaderField(i); if (name == null && value == null) { break; } if (name == null) { responseCode = value; } else { headers.put(name, value); } } return responseCode; } }