From: Alex Rousskov Date: Mon, 18 Nov 2013 15:55:05 +0000 (-0700) Subject: Re-compute Range response content offset after an FTP response was adapted. X-Git-Tag: SQUID_3_5_0_1~507 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5120a38bdd00ace31b7a556724054f8cfbcfe5a1;p=thirdparty%2Fsquid.git Re-compute Range response content offset after an FTP response was adapted. 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. --- diff --git a/src/Server.cc b/src/Server.cc index 1703cddbab..674caf71e9 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -39,6 +39,7 @@ #include "err_detail_type.h" #include "errorpage.h" #include "fd.h" +#include "HttpHdrContRange.h" #include "HttpReply.h" #include "HttpRequest.h" #include "Server.h" @@ -525,6 +526,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 * diff --git a/src/http.cc b/src/http.cc index d6b78dd71a..accb570c8b 100644 --- a/src/http.cc +++ b/src/http.cc @@ -913,9 +913,6 @@ HttpStateData::haveParsedReplyHeaders() Ctx ctx = ctx_enter(entry->mem_obj->url); HttpReply *rep = finalReply(); - if (rep->sline.status() == Http::scPartialContent && rep->content_range) - currentOffset = rep->content_range->spec.offset; - entry->timestampsSet(); /* Check if object is cacheable or not based on reply code */