]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- changed the way Range requests are handled:
authorrousskov <>
Fri, 25 Sep 1998 02:41:19 +0000 (02:41 +0000)
committerrousskov <>
Fri, 25 Sep 1998 02:41:19 +0000 (02:41 +0000)
- 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.

src/client_side.cc
src/http.cc

index ac916ebdb92f1b6199bb4763f6abb6de194651dc..766deea0aeb7bbb4c6caf67b71962147e91b8311 100644 (file)
@@ -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;
index 0792afdc4a3fbafc0e4099447e2495a828254148..1c64437c0ed4b69970747bb988ade71958c35a8a 100644 (file)
@@ -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: