82 ngx_http_range_header_filter_init,
97 &ngx_http_range_header_filter_module_ctx,
113 ngx_http_range_body_filter_init,
128 &ngx_http_range_body_filter_module_ctx,
149 time_t if_range_time;
160 return ngx_http_next_header_filter(r);
166 return ngx_http_next_header_filter(r);
172 (u_char *)
"bytes=", 6)
182 if (if_range->
len >= 2 && if_range->
data[if_range->
len - 1] ==
'"') {
191 "http ir:%V etag:%V", if_range, etag);
193 if (if_range->
len != etag->
len
230 switch (ngx_http_range_parse(r, ctx, clcf->
max_ranges)) {
239 return ngx_http_range_singlepart_header(r, ctx);
242 return ngx_http_range_multipart_header(r, ctx);
245 return ngx_http_range_not_satisfiable(r);
265 return ngx_http_next_header_filter(r);
274 off_t start, end, size, content_length;
287 while (*p ==
' ') { p++; }
290 if (*p < '0' || *p >
'9') {
294 while (*p >=
'0' && *p <=
'9') {
295 start = start * 10 + *p++ -
'0';
298 while (*p ==
' ') { p++; }
304 while (*p ==
' ') { p++; }
306 if (*p ==
',' || *p ==
'\0') {
307 end = content_length;
316 if (*p < '0' || *p >
'9') {
320 while (*p >=
'0' && *p <=
'9') {
321 end = end * 10 + *p++ -
'0';
324 while (*p ==
' ') { p++; }
326 if (*p !=
',' && *p !=
'\0') {
331 start = content_length - end;
332 end = content_length - 1;
335 if (end >= content_length) {
336 end = content_length;
350 range->
start = start;
369 if (size > content_length) {
385 if (content_range == NULL) {
391 content_range->
hash = 1;
417 return ngx_http_next_header_filter(r);
431 +
sizeof(
CRLF "Content-Type: ") - 1
433 +
sizeof(
CRLF "Content-Range: bytes ") - 1;
457 "Content-Type: %V; charset=%V" CRLF
458 "Content-Range: bytes ",
469 "Content-Type: %V" CRLF
470 "Content-Range: bytes ",
478 "Content-Range: bytes ",
485 sizeof(
"Content-Type: multipart/byteranges; boundary=") - 1
498 "multipart/byteranges; boundary=%0muA",
516 if (range[i].content_range.data == NULL) {
527 + (size_t) (range[i].end - range[i].start);
537 return ngx_http_next_header_filter(r);
549 if (content_range == NULL) {
555 content_range->
hash = 1;
581 return ngx_http_next_body_filter(r, in);
587 return ngx_http_next_body_filter(r, in);
591 return ngx_http_range_singlepart_body(r, ctx, in);
599 return ngx_http_next_body_filter(r, in);
602 if (ngx_http_range_test_overlapped(r, ctx, in) !=
NGX_OK) {
606 return ngx_http_range_multipart_body(r, ctx, in);
631 if (start > range[i].start || last < range[i].end) {
644 "range in overlapped buffers");
663 for (cl = in; cl; cl = cl->
next) {
673 "http range body buf: %O-%O", start, last);
681 if (range->
end <= start || range->
start >= last) {
684 "http range body skip");
696 if (range->
start > start) {
703 buf->
pos += (size_t) (range->
start - start);
707 if (range->
end <= last) {
714 buf->
last -= (size_t) (last - range->
end);
732 return ngx_http_next_body_filter(r, out);
814 b->
pos = buf->
pos + (size_t) range[i].start;
815 b->
last = buf->
pos + (size_t) range[i].end;
842 +
sizeof(
"--" CRLF) - 1);
843 if (b->
pos == NULL) {
862 return ngx_http_next_body_filter(r, out);
867 ngx_http_range_header_filter_init(
ngx_conf_t *cf)
877 ngx_http_range_body_filter_init(
ngx_conf_t *cf)