You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/12/04 19:35:52 UTC
git commit: TS-2351 Make the Range calculations more resilient
Updated Branches:
refs/heads/master 439b504f1 -> 581282d8b
TS-2351 Make the Range calculations more resilient
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/581282d8
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/581282d8
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/581282d8
Branch: refs/heads/master
Commit: 581282d8b0273775ca054a900294c96654b0e73b
Parents: 439b504
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Dec 4 11:35:41 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Dec 4 11:35:44 2013 -0700
----------------------------------------------------------------------
proxy/http/HttpTransact.cc | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/581282d8/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index d6b7605..991e1bf 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -8684,14 +8684,24 @@ HttpTransact::change_response_header_because_of_range_request(State *s, HTTPHdr
field->value_append(header->m_heap, header->m_mime, range_type, sizeof(range_type) - 1);
header->field_attach(field);
+ // TODO: There's a known bug here where the Content-Length is not correct for multi-part
+ // Range: requests.
header->set_content_length(s->range_output_cl);
- } else if (s->cache_info.object_read) {
- char numbers[RANGE_NUMBERS_LENGTH];
- header->field_delete(MIME_FIELD_CONTENT_RANGE, MIME_LEN_CONTENT_RANGE);
- field = header->field_create(MIME_FIELD_CONTENT_RANGE, MIME_LEN_CONTENT_RANGE);
- snprintf(numbers, sizeof(numbers), "bytes %" PRId64"-%" PRId64"/%" PRId64, s->ranges[0]._start, s->ranges[0]._end, s->cache_info.object_read->object_size_get());
- field->value_set(header->m_heap, header->m_mime, numbers, strlen(numbers));
- header->field_attach(field);
+ } else {
+ if (s->cache_info.object_read && s->cache_info.object_read->valid()) {
+ // TODO: It's unclear under which conditions we need to update the Content-Range: header,
+ // many times it's already set correctly before calling this. For now, always try do it
+ // when we have the information for it available.
+ // TODO: Also, it's unclear as to why object_read->valid() is not always true here.
+ char numbers[RANGE_NUMBERS_LENGTH];
+ header->field_delete(MIME_FIELD_CONTENT_RANGE, MIME_LEN_CONTENT_RANGE);
+ field = header->field_create(MIME_FIELD_CONTENT_RANGE, MIME_LEN_CONTENT_RANGE);
+ snprintf(numbers, sizeof(numbers), "bytes %" PRId64"-%" PRId64"/%" PRId64, s->ranges[0]._start, s->ranges[0]._end,
+ s->cache_info.object_read->object_size_get());
+ field->value_set(header->m_heap, header->m_mime, numbers, strlen(numbers));
+ header->field_attach(field);
+ }
+ // Always update the Content-Length: header.
header->set_content_length(s->range_output_cl);
}
}