From: rousskov <> Date: Fri, 25 Sep 1998 02:41:19 +0000 (+0000) Subject: - changed the way Range requests are handled: X-Git-Tag: SQUID_3_0_PRE1~2635 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5d679edb789503f04bb9466dd3e8f9f19a263e31;p=thirdparty%2Fsquid.git - changed the way Range requests are handled: - do not "advertise" our ability to process ranges at all - on hits, handle simple ranges and forward complex ones - on misses, fetch the whole document for simple ranges and forward range request for complex ranges The change is supposed to decrease the number of cases when clients such as Adobe acrobat reader get confused when we send a "200" response instead of "206" (because we cannot handle complex ranges, even for hits) Note: Support for complex ranges requires storage of partial objects. --- diff --git a/src/client_side.cc b/src/client_side.cc index ac916ebdb9..766deea0ae 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.401 1998/09/22 23:14:34 wessels Exp $ + * $Id: client_side.cc,v 1.402 1998/09/24 20:41:19 rousskov Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1041,9 +1041,6 @@ clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep) httpHeaderPutStr(hdr, http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION, request->flags.proxy_keepalive ? "keep-alive" : "close"); - /* Accept-Range header for cached objects if not there already */ - if (is_hit && !httpHeaderHas(hdr, HDR_ACCEPT_RANGES)) - httpHeaderPutStr(hdr, HDR_ACCEPT_RANGES, "bytes"); #if ADD_X_REQUEST_URI /* * Knowing the URI of the request is useful when debugging persistent @@ -1624,6 +1621,11 @@ clientProcessRequest2(clientHttpRequest * http) http->entry = NULL; ipcacheReleaseInvalid(r->host); return LOG_TCP_CLIENT_REFRESH_MISS; + } else if (r->range && httpHdrRangeWillBeComplex(r->range)) { + /* some clients break if we return "200 OK" for a Range request + * and we _will_ return 200 if ranges happen to bee too complex */ + http->entry = NULL; + return LOG_TCP_MISS; } else { http->entry = e; return LOG_TCP_HIT; diff --git a/src/http.cc b/src/http.cc index 0792afdc4a..1c64437c0e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.324 1998/09/23 20:13:51 wessels Exp $ + * $Id: http.cc,v 1.325 1998/09/24 20:41:21 rousskov Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -570,7 +570,7 @@ httpBuildRequestHeader(request_t * request, LOCAL_ARRAY(char, bbuf, BBUF_SZ); String strConnection = StringNull; const HttpHeader *hdr_in = &orig_request->header; - int filter_range; + int we_do_ranges; const HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; httpHeaderInit(hdr_out, hoRequest); @@ -578,11 +578,20 @@ httpBuildRequestHeader(request_t * request, if (entry && entry->lastmod > -1 && request->method == METHOD_GET) httpHeaderPutTime(hdr_out, HDR_IF_MODIFIED_SINCE, entry->lastmod); - /* decide if we want to filter out Range specs - * no reason to filter out if the reply will not be cachable - * or if we cannot parse the specs */ - filter_range = - orig_request->range && orig_request->flags.cachable; + /* decide if we want to do Ranges ourselves + * (and fetch the whole object now) + * We want to handle Ranges ourselves iff + * - we can actually parse client Range specs + * - the specs are expected to be simple enough (e.g. no out-of-order ranges) + * - reply will be cachable + * (If the reply will be uncachable we have to though it away after + * serving this request, so it is better to forward ranges to + * the server and fetch only the requested content) + */ + we_do_ranges = + orig_request->range && orig_request->flags.cachable && !httpHdrRangeWillBeComplex(orig_request->range); + debug(11, 8) ("httpBuildRequestHeader: range specs: %p, cachable: %d; we_do_ranges: %d\n", + orig_request->range, orig_request->flags.cachable, we_do_ranges); strConnection = httpHeaderGetList(hdr_in, HDR_CONNECTION); while ((e = httpHeaderGetEntry(hdr_in, &pos))) { @@ -617,7 +626,8 @@ httpBuildRequestHeader(request_t * request, break; case HDR_RANGE: case HDR_IF_RANGE: - if (!filter_range) + case HDR_REQUEST_RANGE: + if (!we_do_ranges) httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e)); break; case HDR_PROXY_CONNECTION: