Efficiency improvements for #5977 (#5998)

Improve efficiency for non wrapped response for cache-contro
This commit is contained in:
Greg Wilkins 2021-02-23 12:56:22 +01:00 committed by GitHub
parent b836c2fda3
commit c0b0f80567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -181,7 +181,13 @@ public class ResourceService
public void setCacheControl(HttpField cacheControl)
{
_cacheControl = cacheControl;
if (cacheControl == null)
_cacheControl = null;
if (cacheControl.getHeader() != HttpHeader.CACHE_CONTROL)
throw new IllegalArgumentException("!Cache-Control");
_cacheControl = cacheControl instanceof PreEncodedHttpField
? cacheControl
: new PreEncodedHttpField(cacheControl.getHeader(), cacheControl.getValue());
}
public List<String> getGzipEquivalentFileExtensions()
@ -828,12 +834,12 @@ public class ResourceService
{
Response r = (Response)response;
r.putHeaders(content, contentLength, _etags);
HttpFields f = r.getHttpFields();
if (_acceptRanges && !response.containsHeader(HttpHeader.ACCEPT_RANGES.asString()))
f.put(ACCEPT_RANGES);
HttpFields fields = r.getHttpFields();
if (_acceptRanges && !fields.contains(HttpHeader.ACCEPT_RANGES))
fields.put(ACCEPT_RANGES);
if (_cacheControl != null && !response.containsHeader(HttpHeader.CACHE_CONTROL.asString()))
f.put(_cacheControl);
if (_cacheControl != null && !fields.contains(HttpHeader.CACHE_CONTROL))
fields.put(_cacheControl);
}
else
{