]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Re-compute Range response content offset after an FTP response was adapted.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 21 Nov 2013 21:54:29 +0000 (14:54 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 21 Nov 2013 21:54:29 +0000 (14:54 -0700)
Moved HTTP-only offset calculation code to the general ServerStateData code so
that [converted-to-HTTP] FTP responses can use it. FTP code computes the range
offset on its own earlier, but we must REcalculate in case the response is
adapted into a response with a different (or no) content range.

src/Server.cc
src/http.cc

index efb1071cd04af6819fe6ec79444264b1bd18910b..cef1fb2b12a9e1cbe526cea5d21655001e3ab997 100644 (file)
@@ -39,6 +39,7 @@
 #include "fd.h"
 #include "err_detail_type.h"
 #include "errorpage.h"
+#include "HttpHdrContRange.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "Server.h"
@@ -522,6 +523,11 @@ ServerStateData::haveParsedReplyHeaders()
 {
     Must(theFinalReply);
     maybePurgeOthers();
+
+    // adaptation may overwrite old offset computed using the virgin response
+    const bool partial = theFinalReply->content_range &&
+                         theFinalReply->sline.status() == Http::scPartialContent;
+    currentOffset = partial ? theFinalReply->content_range->spec.offset : 0;
 }
 
 HttpRequest *
index 5badfcce2040cfbb8ee430456472f133feab34db..d11e025a23d7c8013d7ded88946f11462ba67606 100644 (file)
@@ -924,10 +924,6 @@ HttpStateData::haveParsedReplyHeaders()
     Ctx ctx = ctx_enter(entry->mem_obj->url);
     HttpReply *rep = finalReply();
 
-    if (rep->sline.status == HTTP_PARTIAL_CONTENT &&
-            rep->content_range)
-        currentOffset = rep->content_range->spec.offset;
-
     entry->timestampsSet();
 
     /* Check if object is cacheable or not based on reply code */