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:
Jayson Raymond 2019-02-04 08:57:37 -08:00 committed by Oleg Kalnichevski
parent f24e6847fb
commit d150f5abae
1 changed files with 4 additions and 7 deletions

View File

@ -151,13 +151,10 @@ class CachedHttpResponseGenerator {
if (transferEncodingIsPresent(response)) {
return;
}
Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN);
if (contentLength == null) {
contentLength = new BasicHeader(HTTP.CONTENT_LEN, Long.toString(entity
.getContentLength()));
response.setHeader(contentLength);
}
// 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.
final Header contentLength = new BasicHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));
response.setHeader(contentLength);
}
private boolean transferEncodingIsPresent(final HttpResponse response) {