return APR_SUCCESS;
}
/* XXX handle partial writes */
-static apr_status_t send_the_file(request_rec *r, apr_file_t *fd,
+static apr_status_t send_the_file(conn_rec *c, apr_file_t *fd,
apr_hdtr_t *hdtr, apr_off_t offset,
apr_size_t length, apr_size_t *nbytes)
{
apr_size_t n = length;
#if APR_HAS_SENDFILE
- if (!r->connection->keepalive) {
+ if (!c->keepalive) {
/* Prepare the socket to be reused */
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
}
- rv = apr_sendfile(r->connection->client->bsock,
+ rv = apr_sendfile(c->client->bsock,
fd, /* The file to send */
hdtr, /* Header and trailer iovecs */
&offset, /* Offset in file to begin sending from */
return APR_SUCCESS;
}
+
/* Note --- ErrorDocument will now work from .htaccess files.
* The AllowOverride of Fileinfo allows webmasters to turn it off
*/
ap_bucket_brigade *more = NULL;
apr_ssize_t bytes_sent = 0, nbytes = 0;
ap_bucket *e;
- request_rec *r = f->r;
+ conn_rec *c = f->c;
core_output_filter_ctx_t *ctx = f->ctx;
apr_ssize_t nvec = 0;
apr_off_t foffset = 0;
if (ctx == NULL) {
- f->ctx = ctx = apr_pcalloc(r->pool, sizeof(core_output_filter_ctx_t));
+ f->ctx = ctx = apr_pcalloc(c->pool, sizeof(core_output_filter_ctx_t));
}
/* If we have a saved brigade, concatenate the new brigade to it */
if (ctx->b) {
}
/* Hijack any bytes in BUFF and prepend it to the brigade. */
- if (r->connection->client->outcnt) {
- e = ap_bucket_create_heap(r->connection->client->outbase,
- r->connection->client->outcnt, 1, NULL);
- r->connection->client->outcnt = 0;
+ if (c->client->outcnt) {
+ e = ap_bucket_create_heap(c->client->outbase,
+ c->client->outcnt, 1, NULL);
+ c->client->outcnt = 0;
AP_BRIGADE_INSERT_HEAD(b, e);
}
hdtr.numtrailers = nvec_trailers;
hdtr.trailers = vec_trailers;
}
- rv = send_the_file(r, fd, &hdtr, foffset, flen, &bytes_sent);
+ rv = send_the_file(c, fd, &hdtr, foffset, flen, &bytes_sent);
}
else {
- rv = writev_it_all(r->connection->client->bsock,
+ rv = writev_it_all(c->client->bsock,
vec, nvec,
nbytes, &bytes_sent);
nbytes = 0; /* in case more points to another brigade */
static unsigned short core_port(const request_rec *r)
{ return DEFAULT_HTTP_PORT; }
-static int core_post_read_req(request_rec *r)
-{
- ap_add_filter("CORE", NULL, r);
- return DECLINED;
-}
-
static void core_register_filter(request_rec *r)
{
int i;
for (i = 0; i < conf->filters->nelts; i++) {
char *foobar = items[i];
- ap_add_filter(foobar, NULL, r);
+ ap_add_filter(foobar, NULL, r, r->connection);
}
}
/* FIXME: I suspect we can eliminate the need for these - Ben */
ap_hook_type_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
ap_hook_access_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
- ap_hook_post_read_request(core_post_read_req, NULL, NULL, AP_HOOK_REALLY_FIRST);
/* define the CORE filter, then register a hook to insert it at
* request-processing time.
r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
r->the_request = NULL;
+ r->output_filters = conn->output_filters;
#ifdef APACHE_XLATE
r->rrx = apr_pcalloc(p, sizeof(struct ap_rr_xlate));
if (r->chunked) {
apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked");
apr_table_unset(r->headers_out, "Content-Length");
- ap_add_filter("BUFFER", NULL, r);
- ap_add_filter("CHUNK", NULL, r);
+ ap_add_filter("BUFFER", NULL, r, r->connection);
+ ap_add_filter("CHUNK", NULL, r, r->connection);
}
if (r->byterange > 1) {
}
}
-API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r)
+API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r,
+ conn_rec *c)
{
ap_filter_rec_t *frec = registered_output_filters;
for (; frec != NULL; frec = frec->next) {
if (!strcasecmp(name, frec->name)) {
- ap_filter_t *f = apr_pcalloc(r->pool, sizeof(*f));
+ apr_pool_t *p = r ? r->pool : c->pool;
+ ap_filter_t *f = apr_pcalloc(p, sizeof(*f));
+ ap_filter_t **outf = r ? &r->output_filters : &c->output_filters;
f->frec = frec;
f->ctx = ctx;
f->r = r;
- f->c = NULL;
+ f->c = c;
- if (INSERT_BEFORE(f, r->output_filters)) {
- f->next = r->output_filters;
- r->output_filters = f;
+ if (INSERT_BEFORE(f, *outf)) {
+ f->next = *outf;
+ *outf = f;
}
else {
- ap_filter_t *fscan = r->output_filters;
+ ap_filter_t *fscan = *outf;
while (!INSERT_BEFORE(f, fscan->next))
fscan = fscan->next;
f->next = fscan->next;
API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *next, ap_bucket_brigade *bb)
{
if (next) {
- if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS) {
+ if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS && next->r) {
next->r->eos_sent = 1;
}
return next->frec->filter_func(next, bb);
ap_bucket_brigade **b)
{
ap_bucket *e;
+ apr_pool_t *p = f->r ? f->r->pool : f->c->pool;
/* If have never stored any data in the filter, then we had better
* create an empty bucket brigade so that we can concat.
*/
if (!(*saveto)) {
- *saveto = ap_brigade_create(f->r->pool);
+ *saveto = ap_brigade_create(p);
}
AP_RING_FOREACH(e, &(*b)->list, ap_bucket, link) {