本文整理了Java中java.net.HttpURLConnection.getHeaderFieldKey()
方法的一些代码示例,展示了HttpURLConnection.getHeaderFieldKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpURLConnection.getHeaderFieldKey()
方法的具体详情如下:
包路径:java.net.HttpURLConnection
类名称:HttpURLConnection
方法名:getHeaderFieldKey
[英]Returns the key for the n
th header field. Some implementations may treat the 0
th header field as special, i.e. as the status line returned by the HTTP server. In this case, #getHeaderField(int) returns the status line, but getHeaderFieldKey(0)
returns null.
[中]返回第n
个标头字段的键。某些实现可能将第0
个头字段视为特殊字段,即HTTP服务器返回的状态行。在本例中,#getHeaderField(int)返回状态行,但getHeaderFieldKey(0)
返回null。
代码示例来源:origin: square/okhttp
@Override public String getHeaderFieldKey(int position) {
return delegate.getHeaderFieldKey(position);
}
代码示例来源:origin: prestodb/presto
@Override public String getHeaderFieldKey(int position) {
return delegate.getHeaderFieldKey(position);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public HttpHeaders getHeaders() {
if (this.headers == null) {
this.headers = new HttpHeaders();
// Header field 0 is the status line for most HttpURLConnections, but not on GAE
String name = this.connection.getHeaderFieldKey(0);
if (StringUtils.hasLength(name)) {
this.headers.add(name, this.connection.getHeaderField(0));
}
int i = 1;
while (true) {
name = this.connection.getHeaderFieldKey(i);
if (!StringUtils.hasLength(name)) {
break;
}
this.headers.add(name, this.connection.getHeaderField(i));
i++;
}
}
return this.headers;
}
代码示例来源:origin: org.springframework/spring-web
@Override
public HttpHeaders getHeaders() {
if (this.headers == null) {
this.headers = new HttpHeaders();
// Header field 0 is the status line for most HttpURLConnections, but not on GAE
String name = this.connection.getHeaderFieldKey(0);
if (StringUtils.hasLength(name)) {
this.headers.add(name, this.connection.getHeaderField(0));
}
int i = 1;
while (true) {
name = this.connection.getHeaderFieldKey(i);
if (!StringUtils.hasLength(name)) {
break;
}
this.headers.add(name, this.connection.getHeaderField(i));
i++;
}
}
return this.headers;
}
代码示例来源:origin: org.jsoup/jsoup
private static LinkedHashMap<String, List<String>> createHeaderMap(HttpURLConnection conn) {
// the default sun impl of conn.getHeaderFields() returns header values out of order
final LinkedHashMap<String, List<String>> headers = new LinkedHashMap<>();
int i = 0;
while (true) {
final String key = conn.getHeaderFieldKey(i);
final String val = conn.getHeaderField(i);
if (key == null && val == null)
break;
i++;
if (key == null || val == null)
continue; // skip http1.1 line
if (headers.containsKey(key))
headers.get(key).add(val);
else {
final ArrayList<String> vals = new ArrayList<>();
vals.add(val);
headers.put(key, vals);
}
}
return headers;
}
代码示例来源:origin: haraldk/TwelveMonkeys
String key = pRemoteConnection.getHeaderFieldKey(i);
代码示例来源:origin: apiman/apiman
@Override public String getHeaderFieldKey(int position) {
return delegate.getHeaderFieldKey(position);
}
代码示例来源:origin: org.codehaus.groovy.modules.http-builder/http-builder
public Header[] getAllHeaders() {
if ( this.headers != null ) return this.headers;
List<Header> headers = new ArrayList<Header>();
// see http://java.sun.com/j2se/1.5.0/docs/api/java/net/HttpURLConnection.html#getHeaderFieldKey(int)
int i= conn.getHeaderFieldKey( 0 ) != null ? 0 : 1;
String key;
while ( ( key = conn.getHeaderFieldKey( i ) ) != null ) {
headers.add( new BasicHeader( key, conn.getHeaderField( i++ ) ) );
}
this.headers = headers.toArray( new Header[headers.size()] );
return this.headers;
}
代码示例来源:origin: jgritman/httpbuilder
public Header[] getAllHeaders() {
if ( this.headers != null ) return this.headers;
List<Header> headers = new ArrayList<Header>();
// see http://java.sun.com/j2se/1.5.0/docs/api/java/net/HttpURLConnection.html#getHeaderFieldKey(int)
int i= conn.getHeaderFieldKey( 0 ) != null ? 0 : 1;
String key;
while ( ( key = conn.getHeaderFieldKey( i ) ) != null ) {
headers.add( new BasicHeader( key, conn.getHeaderField( i++ ) ) );
}
this.headers = headers.toArray( new Header[headers.size()] );
return this.headers;
}
代码示例来源:origin: JinBoy23520/CoderToDeveloperByTCLer
public static Map<String, String> getHttpResponseHeader(HttpURLConnection http) {
Map<String, String> header = new LinkedHashMap<String, String>();
for (int i = 0;; i++) {
String mine = http.getHeaderField(i);
if (mine == null)
break;
header.put(http.getHeaderFieldKey(i), mine);
}
return header;
}
代码示例来源:origin: excelsior-oss/restler
private Stream<String> getCookies(HttpURLConnection conn) {
String headerName;
for (int i = 1; (headerName = conn.getHeaderFieldKey(i)) != null; i++) {
if (headerName.equals("Set-Cookie")) {
String cookie = conn.getHeaderField(i);
return Arrays.stream(cookie.split(";"));
}
}
return Stream.empty();
}
代码示例来源:origin: org.codelibs/jcifs
@Override
public String getHeaderFieldKey ( int index ) {
handshake();
return this.connection.getHeaderFieldKey(index);
}
代码示例来源:origin: org.codelibs/spnego
/**
* Get header field key at specified index.
*
* @param index
* @return header field key at specified index
*/
public String getHeaderFieldKey(final int index) {
assertConnected();
return this.conn.getHeaderFieldKey(index);
}
代码示例来源:origin: com.jaeksoft/jcifs-krb5-jdk7
public String getHeaderFieldKey(int index) {
try {
handshake();
} catch (IOException ex) { }
return connection.getHeaderFieldKey(index);
}
代码示例来源:origin: AgNO3/jcifs-ng
@Override
public String getHeaderFieldKey ( int index ) {
handshake();
return this.connection.getHeaderFieldKey(index);
}
代码示例来源:origin: jcifs/jcifs
public String getHeaderFieldKey(int index) {
try {
handshake();
} catch (IOException ex) { }
return connection.getHeaderFieldKey(index);
}
代码示例来源:origin: org.samba.jcifs/jcifs
public String getHeaderFieldKey(int index) {
try {
handshake();
} catch (IOException ex) { }
return connection.getHeaderFieldKey(index);
}
代码示例来源:origin: kohsuke/jcifs
public String getHeaderFieldKey(int index) {
try {
handshake();
} catch (IOException ex) { }
return connection.getHeaderFieldKey(index);
}
代码示例来源:origin: com.github.mcpat.gcf/gcf-standard
public final String getHeaderFieldKey(int n) throws IOException {
ensureOpen();
return connection.getHeaderFieldKey(n);
}
代码示例来源:origin: ibinti/bugvm
private Response readResponse() throws IOException {
int responseCode = connection.getResponseCode();
Response.Builder responseBuilder = new Response.Builder(request, responseCode);
for (int i = 0; true; i++) {
String name = connection.getHeaderFieldKey(i);
if (name == null) break;
String value = connection.getHeaderField(i);
responseBuilder.addHeader(name, value);
}
responseBuilder.body(new Dispatcher.RealResponseBody(connection, connection.getInputStream()));
// TODO: set redirectedBy
return responseBuilder.build();
}
}
内容来源于网络,如有侵权,请联系作者删除!