/**
* Returns the value of the named header field.
*
* If called on a connection that sets the same header multiple times
* with possibly different values, only the last value is returned.
*
*
* @param name the name of a header field.
* @return the value of the named header field, or {@code null}
* if there is no such field in the header.
*/
public String getHeaderField(String name) { return null;
}
事实上这个方法在常见实现类里都有被覆写:
比如常见的 HttpURLConnection 中:public String getHeaderField(String var1) { try { this.getInputStream();
} catch (IOException var3) {
;
} return this.cachedHeaders != null
? this.filterHeaderField(var1, this.cachedHeaders.findValue(var1))
: this.filterHeaderField(var1, this.responses.findValue(var1));
}