--- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/client_side.cc 2003-04-06 00:23:10.000000000 -0800 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/client_side.cc 2003-05-20 16:39:13.000000000 -0700 @@ -857,6 +857,7 @@ HttpHdrRangeIter * i = &http->range_iter; size_t available = size; + http->out.offset = i->currentSpec()->offset; while (i->currentSpec() && available) { const size_t copy_sz = lengthToSend(available); /* @@ -901,12 +902,15 @@ */ assert(available >= 0 && i->debt() >= 0 || i->debt() == -1); - if (i->debt() == 0) - /* put terminating boundary for multiparts */ - clientPackTermBound(i->boundary, mb); - - if (!canPackMoreRanges()) - return; + if (!canPackMoreRanges()) { + debug(33, 3) ("clientPackRange: Returning because !canPackMoreRanges.\n"); + + if (i->debt() == 0) + /* put terminating boundary for multiparts */ + clientPackTermBound(i->boundary, mb); + + return; + } off_t next = getNextRangeOffset(); @@ -917,6 +921,8 @@ if (available <= skip) return; + http->out.offset += skip; + available -= skip; *buf += skip; @@ -1123,8 +1129,11 @@ void ClientSocketContext::prepareReply(HttpReply * rep) { - if (http->request->range) - buildRangeHeader(rep); + if (http->request->range) { + httpStatusLineSet(&rep->sline, rep->sline.version, + HTTP_PARTIAL_CONTENT, NULL); + buildRangeHeader(rep); + } } void --- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/MemObject.cc 2003-03-03 17:40:25.000000000 -0800 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/MemObject.cc 2003-05-20 16:16:06.000000000 -0700 @@ -292,7 +292,9 @@ bool MemObject::readAheadPolicyCanRead() const { - return (size_t)endOffset() - getReply()->hdr_sz < lowestMemReaderOffset() + Config.readAheadGap; + + size_t actual_read_ahead_gap = (Config.readAheadGap <<10); + return (size_t)endOffset() - getReply()->hdr_sz < lowestMemReaderOffset() + actual_read_ahead_gap; } void --- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/client_side_reply.cc 2003-05-11 06:53:03.000000000 -0700 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/client_side_reply.cc 2003-05-20 16:17:59.000000000 -0700 @@ -1579,14 +1579,14 @@ * I suspec this test is incorrect though, as we can extract ranges from * a fully cached object */ - if (r->flags.range) { - /* XXX: test to see if we can satisfy the range with the cached object */ - debug(85, 3) ("clientProcessRequest2: force MISS due to range presence\n"); - http->entry = NULL; - http->logType = LOG_TCP_MISS; - doGetMoreData(); - return; - } + //if (r->flags.range) { + /* XXX: test to see if we can satisfy the range with the cached object */ + // debug(85, 3) ("clientProcessRequest2: force MISS due to range presence\n"); + // http->entry = NULL; + // http->logType = LOG_TCP_MISS; + // doGetMoreData(); + // return; + //} debug(85, 3) ("clientProcessRequest2: default HIT\n"); http->logType = LOG_TCP_HIT; @@ -1924,6 +1924,17 @@ char *buf = next()->readBuffer.data; char *body_buf = buf + rep->hdr_sz; + // Do canonizing before printing. Should canonizing twice have the same result (idempotent?)? + if (http->request->range) { + HttpHdrRange * request_range = http->request->range; + request_range->canonize(rep); + next()->readBuffer.offset = request_range->firstOffset(); + } + + // Check to make sure we're really responsible for the ranges. + if ((!http->request->range)) + next()->readBuffer.offset = 0; + if (next()->readBuffer.offset != 0) { if (next()->readBuffer.offset > body_size) { /* Can't use any of the body we recieved. send nothing */ --- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/HttpHdrRange.cc 2003-03-05 22:21:36.000000000 -0800 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/HttpHdrRange.cc 2003-05-20 16:18:49.000000000 -0700 @@ -586,7 +586,7 @@ /* disabled */ return false; - if ((ssize_t)Config.rangeOffsetLimit >= firstOffset()) + if ((ssize_t)Config.rangeOffsetLimit >= firstOffset() && !(firstOffset() == -1)) /* below the limit */ return false; --- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/cf_parser.h 2003-05-20 22:27:02.000000000 -0700 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/cf_parser.h 2003-05-20 16:40:02.000000000 -0700 @@ -808,7 +808,7 @@ return 1; }; if (!strcmp(token, "range_offset_limit")) { - parse_b_size_t(&Config.rangeOffsetLimit); + parse_b_none_size_t(&Config.rangeOffsetLimit); return 1; }; if (!strcmp(token, "connect_timeout")) { --- ./squid3_new_5.16_clean_for_bugs/squid-3.0.DEVEL-20030517/src/cache_cf.cc 2003-04-23 23:35:04.000000000 -0700 +++ ./squid3_new_5.16_range_testing/squid-3.0.DEVEL-20030517/src/cache_cf.cc 2003-05-20 16:44:56.000000000 -0700 @@ -88,6 +88,7 @@ static void default_all(void); static void defaults_if_none(void); static int parse_line(char *); +static void parseBytesNoneLine(size_t * bptr, const char *units); static void parseBytesLine(size_t * bptr, const char *units); static size_t parseBytesUnits(const char *unit); static void free_all(void); @@ -654,6 +655,51 @@ } static void +parseBytesNoneLine(size_t * bptr, const char *units) +{ + char *token; + double d; + size_t m; + size_t u; + + if ((u = parseBytesUnits(units)) == 0) + self_destruct(); + + if ((token = strtok(NULL, w_space)) == NULL) + self_destruct(); + + // Check for 'none' + char * none_idx = strstr(token, "none"); + if (none_idx != 0) { + d = -1.0; + (*bptr) = static_cast(-1); + debug(3, 0) ("(*btpr) is: %d.\n", (int) (*bptr)); + return; + } else + d = xatof(token); + + m = u; /* default to 'units' if none specified */ + + if (0.0 == d) { + (void) 0; + } else if ((token = strtok(NULL, w_space)) == NULL) { + debug(3, 0) ("WARNING: No units on '%s', assuming %f %s\n", + config_input_line, d, units); + } else if ((m = parseBytesUnits(token)) == 0) { + self_destruct(); + } + + *bptr = static_cast(m * d / u); + + // Reset to be -1 if we have a problem. + if ((int) (*bptr) <= -1) { + (*bptr) = static_cast(-1); + debug(3, 0) ("WARNING: Negative argument on '%s', assuming 'none'.\n", + config_input_line); + } +} + +static void parseBytesLine(size_t * bptr, const char *units) { char *token; @@ -2324,6 +2370,11 @@ i = GetInteger(); *var = (size_t) i; } +static void +parse_b_none_size_t(size_t * var) +{ + parseBytesNoneLine(var, B_BYTES_STR); +} static void parse_b_size_t(size_t * var)