Fields Summary |
---|
private static final String | LOGTAG |
public static final int | CONN_CLOSEindicate HTTP 1.0 connection close after the response |
public static final int | CONN_KEEP_ALIVEindicate HTTP 1.1 connection keep alive |
public static final int | NO_CONN_TYPE |
public static final long | NO_TRANSFER_ENCODING |
public static final long | NO_CONTENT_LENGTH |
public static final String | TRANSFER_ENCODING |
public static final String | CONTENT_LEN |
public static final String | CONTENT_TYPE |
public static final String | CONTENT_ENCODING |
public static final String | CONN_DIRECTIVE |
public static final String | LOCATION |
public static final String | PROXY_CONNECTION |
public static final String | WWW_AUTHENTICATE |
public static final String | PROXY_AUTHENTICATE |
public static final String | CONTENT_DISPOSITION |
public static final String | ACCEPT_RANGES |
public static final String | EXPIRES |
public static final String | CACHE_CONTROL |
public static final String | LAST_MODIFIED |
public static final String | ETAG |
public static final String | SET_COOKIE |
public static final String | PRAGMA |
public static final String | REFRESH |
private static final int | HASH_TRANSFER_ENCODING |
private static final int | HASH_CONTENT_LEN |
private static final int | HASH_CONTENT_TYPE |
private static final int | HASH_CONTENT_ENCODING |
private static final int | HASH_CONN_DIRECTIVE |
private static final int | HASH_LOCATION |
private static final int | HASH_PROXY_CONNECTION |
private static final int | HASH_WWW_AUTHENTICATE |
private static final int | HASH_PROXY_AUTHENTICATE |
private static final int | HASH_CONTENT_DISPOSITION |
private static final int | HASH_ACCEPT_RANGES |
private static final int | HASH_EXPIRES |
private static final int | HASH_CACHE_CONTROL |
private static final int | HASH_LAST_MODIFIED |
private static final int | HASH_ETAG |
private static final int | HASH_SET_COOKIE |
private static final int | HASH_PRAGMA |
private static final int | HASH_REFRESH |
private static final int | IDX_TRANSFER_ENCODING |
private static final int | IDX_CONTENT_LEN |
private static final int | IDX_CONTENT_TYPE |
private static final int | IDX_CONTENT_ENCODING |
private static final int | IDX_CONN_DIRECTIVE |
private static final int | IDX_LOCATION |
private static final int | IDX_PROXY_CONNECTION |
private static final int | IDX_WWW_AUTHENTICATE |
private static final int | IDX_PROXY_AUTHENTICATE |
private static final int | IDX_CONTENT_DISPOSITION |
private static final int | IDX_ACCEPT_RANGES |
private static final int | IDX_EXPIRES |
private static final int | IDX_CACHE_CONTROL |
private static final int | IDX_LAST_MODIFIED |
private static final int | IDX_ETAG |
private static final int | IDX_SET_COOKIE |
private static final int | IDX_PRAGMA |
private static final int | IDX_REFRESH |
private static final int | HEADER_COUNT |
private long | transferEncoding |
private long | contentLength |
private int | connectionType |
private ArrayList | cookies |
private String[] | mHeaders |
private static final String[] | sHeaderNames |
private ArrayList | mExtraHeaderNames |
private ArrayList | mExtraHeaderValues |
Methods Summary |
---|
public java.lang.String | getAcceptRanges()
return mHeaders[IDX_ACCEPT_RANGES];
|
public java.lang.String | getCacheControl()
return mHeaders[IDX_CACHE_CONTROL];
|
public int | getConnectionType()
return connectionType;
|
public java.lang.String | getContentDisposition()
return mHeaders[IDX_CONTENT_DISPOSITION];
|
public java.lang.String | getContentEncoding()
return mHeaders[IDX_CONTENT_ENCODING];
|
public long | getContentLength()
return contentLength;
|
public java.lang.String | getContentType()
return mHeaders[IDX_CONTENT_TYPE];
|
public java.lang.String | getEtag()
return mHeaders[IDX_ETAG];
|
public java.lang.String | getExpires()
return mHeaders[IDX_EXPIRES];
|
public void | getHeaders(android.net.http.Headers$HeaderCallback hcb)Reports all non-null headers to the callback
for (int i = 0; i < HEADER_COUNT; i++) {
String h = mHeaders[i];
if (h != null) {
hcb.header(sHeaderNames[i], h);
}
}
int extraLen = mExtraHeaderNames.size();
for (int i = 0; i < extraLen; i++) {
if (Config.LOGV) {
HttpLog.v("Headers.getHeaders() extra: " + i + " " +
mExtraHeaderNames.get(i) + " " + mExtraHeaderValues.get(i));
}
hcb.header(mExtraHeaderNames.get(i),
mExtraHeaderValues.get(i));
}
|
public java.lang.String | getLastModified()
return mHeaders[IDX_LAST_MODIFIED];
|
public java.lang.String | getLocation()
return mHeaders[IDX_LOCATION];
|
public java.lang.String | getPragma()
return mHeaders[IDX_PRAGMA];
|
public java.lang.String | getProxyAuthenticate()
return mHeaders[IDX_PROXY_AUTHENTICATE];
|
public java.lang.String | getRefresh()
return mHeaders[IDX_REFRESH];
|
public java.util.ArrayList | getSetCookie()
return this.cookies;
|
public long | getTransferEncoding()
return transferEncoding;
|
public java.lang.String | getWwwAuthenticate()
return mHeaders[IDX_WWW_AUTHENTICATE];
|
public void | parseHeader(org.apache.http.util.CharArrayBuffer buffer)
int pos = CharArrayBuffers.setLowercaseIndexOf(buffer, ':");
if (pos == -1) {
return;
}
String name = buffer.substringTrimmed(0, pos);
if (name.length() == 0) {
return;
}
pos++;
String val = buffer.substringTrimmed(pos, buffer.length());
if (HttpLog.LOGV) {
HttpLog.v("hdr " + buffer.length() + " " + buffer);
}
switch (name.hashCode()) {
case HASH_TRANSFER_ENCODING:
if (name.equals(TRANSFER_ENCODING)) {
mHeaders[IDX_TRANSFER_ENCODING] = val;
HeaderElement[] encodings = BasicHeaderValueParser.DEFAULT
.parseElements(buffer, new ParserCursor(pos,
buffer.length()));
// The chunked encoding must be the last one applied RFC2616,
// 14.41
int len = encodings.length;
if (HTTP.IDENTITY_CODING.equalsIgnoreCase(val)) {
transferEncoding = ContentLengthStrategy.IDENTITY;
} else if ((len > 0)
&& (HTTP.CHUNK_CODING
.equalsIgnoreCase(encodings[len - 1].getName()))) {
transferEncoding = ContentLengthStrategy.CHUNKED;
} else {
transferEncoding = ContentLengthStrategy.IDENTITY;
}
}
break;
case HASH_CONTENT_LEN:
if (name.equals(CONTENT_LEN)) {
mHeaders[IDX_CONTENT_LEN] = val;
try {
contentLength = Long.parseLong(val);
} catch (NumberFormatException e) {
if (Config.LOGV) {
Log.v(LOGTAG, "Headers.headers(): error parsing"
+ " content length: " + buffer.toString());
}
}
}
break;
case HASH_CONTENT_TYPE:
if (name.equals(CONTENT_TYPE)) {
mHeaders[IDX_CONTENT_TYPE] = val;
}
break;
case HASH_CONTENT_ENCODING:
if (name.equals(CONTENT_ENCODING)) {
mHeaders[IDX_CONTENT_ENCODING] = val;
}
break;
case HASH_CONN_DIRECTIVE:
if (name.equals(CONN_DIRECTIVE)) {
mHeaders[IDX_CONN_DIRECTIVE] = val;
setConnectionType(buffer, pos);
}
break;
case HASH_LOCATION:
if (name.equals(LOCATION)) {
mHeaders[IDX_LOCATION] = val;
}
break;
case HASH_PROXY_CONNECTION:
if (name.equals(PROXY_CONNECTION)) {
mHeaders[IDX_PROXY_CONNECTION] = val;
setConnectionType(buffer, pos);
}
break;
case HASH_WWW_AUTHENTICATE:
if (name.equals(WWW_AUTHENTICATE)) {
mHeaders[IDX_WWW_AUTHENTICATE] = val;
}
break;
case HASH_PROXY_AUTHENTICATE:
if (name.equals(PROXY_AUTHENTICATE)) {
mHeaders[IDX_PROXY_AUTHENTICATE] = val;
}
break;
case HASH_CONTENT_DISPOSITION:
if (name.equals(CONTENT_DISPOSITION)) {
mHeaders[IDX_CONTENT_DISPOSITION] = val;
}
break;
case HASH_ACCEPT_RANGES:
if (name.equals(ACCEPT_RANGES)) {
mHeaders[IDX_ACCEPT_RANGES] = val;
}
break;
case HASH_EXPIRES:
if (name.equals(EXPIRES)) {
mHeaders[IDX_EXPIRES] = val;
}
break;
case HASH_CACHE_CONTROL:
if (name.equals(CACHE_CONTROL)) {
mHeaders[IDX_CACHE_CONTROL] = val;
}
break;
case HASH_LAST_MODIFIED:
if (name.equals(LAST_MODIFIED)) {
mHeaders[IDX_LAST_MODIFIED] = val;
}
break;
case HASH_ETAG:
if (name.equals(ETAG)) {
mHeaders[IDX_ETAG] = val;
}
break;
case HASH_SET_COOKIE:
if (name.equals(SET_COOKIE)) {
mHeaders[IDX_SET_COOKIE] = val;
cookies.add(val);
}
break;
case HASH_PRAGMA:
if (name.equals(PRAGMA)) {
mHeaders[IDX_PRAGMA] = val;
}
break;
case HASH_REFRESH:
if (name.equals(REFRESH)) {
mHeaders[IDX_REFRESH] = val;
}
break;
default:
mExtraHeaderNames.add(name);
mExtraHeaderValues.add(val);
}
|
public void | setAcceptRanges(java.lang.String value)
mHeaders[IDX_ACCEPT_RANGES] = value;
|
public void | setCacheControl(java.lang.String value)
mHeaders[IDX_CACHE_CONTROL] = value;
|
private void | setConnectionType(org.apache.http.util.CharArrayBuffer buffer, int pos)
if (CharArrayBuffers.containsIgnoreCaseTrimmed(
buffer, pos, HTTP.CONN_CLOSE)) {
connectionType = CONN_CLOSE;
} else if (CharArrayBuffers.containsIgnoreCaseTrimmed(
buffer, pos, HTTP.CONN_KEEP_ALIVE)) {
connectionType = CONN_KEEP_ALIVE;
}
|
public void | setContentDisposition(java.lang.String value)
mHeaders[IDX_CONTENT_DISPOSITION] = value;
|
public void | setContentEncoding(java.lang.String value)
mHeaders[IDX_CONTENT_ENCODING] = value;
|
public void | setContentLength(long value)
this.contentLength = value;
|
public void | setContentType(java.lang.String value)
mHeaders[IDX_CONTENT_TYPE] = value;
|
public void | setEtag(java.lang.String value)
mHeaders[IDX_ETAG] = value;
|
public void | setExpires(java.lang.String value)
mHeaders[IDX_EXPIRES] = value;
|
public void | setLastModified(java.lang.String value)
mHeaders[IDX_LAST_MODIFIED] = value;
|
public void | setLocation(java.lang.String value)
mHeaders[IDX_LOCATION] = value;
|
public void | setProxyAuthenticate(java.lang.String value)
mHeaders[IDX_PROXY_AUTHENTICATE] = value;
|
public void | setWwwAuthenticate(java.lang.String value)
mHeaders[IDX_WWW_AUTHENTICATE] = value;
|