You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by vm...@apache.org on 2019/01/30 20:52:55 UTC
[trafficserver] branch master updated: Cached object's size can be
used as content length for 304 response
This is an automated email from the ASF dual-hosted git repository.
vmamidi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 23cdf76 Cached object's size can be used as content length for 304 response
23cdf76 is described below
commit 23cdf765e3ca4ac15c7fdbe83ca67cc0a36bcdda
Author: Vijay Mamidi <vi...@yahoo.com>
AuthorDate: Mon Jan 28 21:45:34 2019 -0800
Cached object's size can be used as content length for 304 response
---
proxy/http/HttpTransact.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index aba6edc..68ff019 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -6622,7 +6622,13 @@ HttpTransact::handle_content_length_header(State *s, HTTPHdr *header, HTTPHdr *b
TxnDebug("http_trans", "[handle_content_length_header] RESPONSE cont len in hdr is %" PRId64, header->get_content_length());
} else {
// No content length header.
- if (s->source == SOURCE_CACHE) {
+ // If the source is cache or server returned 304 response,
+ // we can try to get the content length based on object size.
+ // Also, we should check the scenario of server sending't a unexpected 304 response for a non conditional request( no cached
+ // object )
+ if (s->source == SOURCE_CACHE ||
+ (s->source == SOURCE_HTTP_ORIGIN_SERVER && s->hdr_info.server_response.status_get() == HTTP_STATUS_NOT_MODIFIED &&
+ s->cache_info.object_read != nullptr)) {
// If there is no content-length header, we can
// insert one since the cache knows definitely
// how long the object is unless we're in a
@@ -6637,18 +6643,14 @@ HttpTransact::handle_content_length_header(State *s, HTTPHdr *header, HTTPHdr *b
} else if (s->range_setup == RANGE_NOT_TRANSFORM_REQUESTED) {
// if we are doing a single Range: request, calculate the new
// C-L: header
+ // either the object is in cache or origin returned a 304 Not Modified response. We can still turn this into a proper Range
+ // response from the cached object.
change_response_header_because_of_range_request(s, header);
s->hdr_info.trust_response_cl = true;
} else {
header->set_content_length(cl);
s->hdr_info.trust_response_cl = true;
}
- } else if (s->source == SOURCE_HTTP_ORIGIN_SERVER && s->hdr_info.server_response.status_get() == HTTP_STATUS_NOT_MODIFIED &&
- s->range_setup == RANGE_NOT_TRANSFORM_REQUESTED) {
- // In this case, we had a cached object, possibly chunked encoded (so we don't have a CL: header), but the origin did a
- // 304 Not Modified response. We can still turn this into a proper Range response from the cached object.
- change_response_header_because_of_range_request(s, header);
- s->hdr_info.trust_response_cl = true;
} else {
// Check to see if there is no content length
// header because the response precludes a