Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 55773 invoked by uid 500); 17 Dec 2000 20:58:31 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 55762 invoked by uid 500); 17 Dec 2000 20:58:31 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 17 Dec 2000 20:58:31 -0000 Message-ID: <20001217205831.55758.qmail@locus.apache.org> From: rbb@locus.apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/http http_protocol.c rbb 00/12/17 12:58:30 Modified: . CHANGES modules/http http_protocol.c Log: Make the server return HTTP_RANGE_NOT_SATISFIABLE if the all of the requested ranges begin after the end of the response. Revision Changes Path 1.9 +3 -0 httpd-2.0/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/httpd-2.0/CHANGES,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- CHANGES 2000/12/17 18:04:13 1.8 +++ CHANGES 2000/12/17 20:58:29 1.9 @@ -1,4 +1,7 @@ Changes with Apache 2.0b1 + *) Return HTTP_RANGE_NOT_SATISFIABLE if the every range requested starts + after the end of the response. [Ryan Bloom] + *) Get byterange requests working with responses that do not have a content-length. Because of the way byterange requests work, we have to have all of the data before we can actually do the byterange, so we 1.257 +31 -6 httpd-2.0/modules/http/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v retrieving revision 1.256 retrieving revision 1.257 diff -u -r1.256 -r1.257 --- http_protocol.c 2000/12/17 18:04:14 1.256 +++ http_protocol.c 2000/12/17 20:58:30 1.257 @@ -181,7 +181,7 @@ *end = clength - 1; if (*start > *end) - return 0; + return -1; return (*start > 0 || *end < clength - 1); } @@ -224,10 +224,16 @@ char *current; const char *bound_head; int clength = 0; + apr_status_t rv; + int found = 0; if (!ctx) { int num_ranges = ap_set_byterange(r); + if (num_ranges == -1) { + ap_remove_output_filter(f); + return HTTP_RANGE_NOT_SATISFIABLE; + } if (num_ranges == 0) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); @@ -287,7 +293,7 @@ bsend = ap_brigade_create(r->pool); while ((current = ap_getword(r->pool, &r->range, ',')) && - parse_byterange(current, clength, &range_start, &range_end)) { + (rv = parse_byterange(current, clength, &range_start, &range_end))) { const char *str; apr_size_t n; const char *range; @@ -297,6 +303,13 @@ apr_size_t segment_length; apr_off_t curr_offset = 0; + if (rv == -1) { + continue; + } + else { + found = 1; + } + /* ### this is so bogus, but not dealing with it right now */ range = loc = apr_pcalloc(r->pool, range_length + 1); @@ -373,6 +386,12 @@ AP_BRIGADE_INSERT_TAIL(bsend, e); } + if (found == 0) { + ap_remove_output_filter(f); + r->status = HTTP_OK; + return HTTP_RANGE_NOT_SATISFIABLE; + } + if (ctx->num_ranges > 1) { const char *end; @@ -2398,12 +2417,13 @@ ct = make_content_type(r, r->content_type); if (!ap_strchr_c(range, ',')) { + int rv; /* A single range */ - /* parse_byterange() modifies the contents, so make a copy */ - if (!parse_byterange(apr_pstrdup(r->pool, range + 6), r->clength, - &range_start, &range_end)) { - return 0; + /* rvarse_byterange() modifies the contents, so make a copy */ + if ((rv = parse_byterange(apr_pstrdup(r->pool, range + 6), r->clength, + &range_start, &range_end)) <= 0) { + return rv; } apr_table_setn(r->headers_out, "Content-Range", apr_psprintf(r->pool, "bytes " BYTERANGE_FMT, @@ -3339,6 +3359,11 @@ int idx = ap_index_of_response(status); char *custom_response; const char *location = apr_table_get(r->headers_out, "Location"); + + /* At this point, we are starting the response over, so we have to reset + * this value. + */ + r->eos_sent = 0; /* * It's possible that the Location field might be in r->err_headers_out