Some well known proxies respond with Content-Length=0, when returning 304. For robustness, always use the cached entity's content length, as modern browsers do.
This commit is contained in:
parent
1f06087fad
commit
e6ca403d29
|
@ -145,11 +145,10 @@ class CachedHttpResponseGenerator {
|
||||||
if (transferEncodingIsPresent(response)) {
|
if (transferEncodingIsPresent(response)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Header contentLength = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
|
// Some well known proxies respond with Content-Length=0, when returning 304. For robustness, always
|
||||||
if (contentLength == null) {
|
// use the cached entity's content length, as modern browsers do.
|
||||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.length));
|
response.setHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.length));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean transferEncodingIsPresent(final HttpResponse response) {
|
private boolean transferEncodingIsPresent(final HttpResponse response) {
|
||||||
final Header hdr = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
|
final Header hdr = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
|
||||||
|
|
Loading…
Reference in New Issue