byterange_filter.c revision cf8d02ea0c91653917b044529f3133c5a1bb9200
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major/* Licensed to the Apache Software Foundation (ASF) under one or more
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * contributor license agreements. See the NOTICE file distributed with
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * this work for additional information regarding copyright ownership.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * The ASF licenses this file to You under the Apache License, Version 2.0
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * (the "License"); you may not use this file except in compliance with
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * the License. You may obtain a copy of the License at
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Unless required by applicable law or agreed to in writing, software
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * distributed under the License is distributed on an "AS IS" BASIS,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * See the License for the specific language governing permissions and
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * limitations under the License.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * byterange_filter.c --- HTTP byterange filter and friends.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major#include "http_log.h" /* For errors detected in basic auth common
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * support code... */
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major#include "apr_date.h" /* For apr_date_parse_http and APR_DATE_BAD */
char *errp;
if (!dash) {
if (*dash) {
if (*start < 0) {
*start = 0;
typedef struct byterange_ctx {
int num_ranges;
char *boundary;
char *bound_head;
* Here we try to be compatible with clients that want multipart/x-byteranges
* instead of multipart/byteranges (also see above), as per HTTP/1.1. We
const char *ua;
request_rec *r = f->r;
apr_bucket *e;
char *current;
int found = 0;
int num_ranges;
e = APR_BUCKET_NEXT(e)) {
if (num_ranges == 0) {
if (orig_ct) {
NULL);
NULL);
&range_end))) {
char *ts;
c->bucket_alloc);
const char *str;
if (found == 0) {
char *end;
const char *range;
const char *if_range;
const char *match;
const char *ct;
int num_ranges;
if (r->assbackwards) {
* send multipart/x-byteranges instead of multipart/byteranges for
return num_ranges;