Merge pull request #135 from JaysonRaymond/master

Always use the cached entity's content length.
This commit is contained in:
Oleg Kalnichevski 2019-02-07 19:11:57 +01:00 committed by GitHub
commit f59702d6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -145,10 +145,9 @@ class CachedHttpResponseGenerator {
if (transferEncodingIsPresent(response)) {
return;
}
final Header contentLength = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
if (contentLength == null) {
response.setHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.length));
}
// 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.
response.setHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.length));
}
private boolean transferEncodingIsPresent(final HttpResponse response) {