in src/main/java/com/twitter/whiskey/net/SpdyStream.java [253:320]
void onHeader(Header header) throws IOException {
if (INVALID_HEADERS.contains(header.getKey())) {
//throw new SpdyProtocolException("invalid header for SPDY response: " + header.getKey());
return;
}
switch(header.getKey()) {
case ":status":
Integer status;
try {
status = Integer.valueOf(header.getValue().substring(0, 3));
} catch (NumberFormatException e) {
throw new IOException("invalid HTTP response: " + header.getValue());
}
onStatus(status);
// Don't include SPDY protocol headers in response headers
return;
case ":version":
// Don't include SPDY protocol headers in response headers
return;
case Headers.LOCATION:
try {
Request currentRequest = operation.getCurrentRequest();
redirectURL = new URL(currentRequest.getUrl(), header.getValue());
} catch (MalformedURLException e) {
throw new IOException(
"malformed URL received for redirect: " + header.getValue(), e);
}
break;
case Headers.CONTENT_ENCODING:
String value = header.getValue();
if (value.equalsIgnoreCase("gzip")) {
compressed = true;
inflater = new ZlibInflater(ZlibInflater.Wrapper.GZIP);
} else if (value.equalsIgnoreCase("zlib")) {
compressed = true;
inflater = new ZlibInflater(ZlibInflater.Wrapper.ZLIB);
} else if (value.equalsIgnoreCase("deflate")) {
compressed = true;
inflater = new ZlibInflater(ZlibInflater.Wrapper.UNKNOWN);
} else {
break;
}
if (expectedContentLength > 0) {
int approximateLength = estimateContentLength(expectedContentLength);
operation.getBodyFuture().setExpectedLength(approximateLength);
}
return;
case Headers.CONTENT_LENGTH:
expectedContentLength = header.getIntegerValue();
if (expectedContentLength <= 0) break;
if (compressed) {
operation.getBodyFuture().setExpectedLength(estimateContentLength(expectedContentLength));
} else {
operation.getBodyFuture().setExpectedLength(expectedContentLength);
}
break;
}
operation.getHeadersFuture().provide(header);
}