From 1826f624eb6167c5aab7d4bb877ec67a02cc43e7 Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Thu, 18 Apr 2002 22:50:54 +0000 Subject: [PATCH] Switch ap_http_filter to use ap_get_brigade and apr_brigade_flatten instead of ap_getline - this prevents some odd looping issues that can cause problems. Also, when we call get_mime_headers to read the trailers, we need to reset our ctx->state to BODY_NONE - there should only be MIME-header information (followed by a blank CRLF line) - and we don't know how much data there will be - so it is by definition BODY_NONE. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94704 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_protocol.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 6c87ae867a..331a4a55f9 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -831,10 +831,19 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, /* We can't read the chunk until after sending 100 if required. */ if (ctx->state == BODY_CHUNK) { char line[30]; + apr_bucket_brigade *bb; + apr_size_t len = 30; + + bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); + + rv = ap_get_brigade(f->next, bb, AP_MODE_GETLINE, + APR_BLOCK_READ, 0); - if ((rv = ap_getline(line, sizeof(line), f->r, 0)) < 0) { + if (rv != APR_SUCCESS) { return rv; } + apr_brigade_flatten(bb, line, &len); + ctx->remaining = get_chunk_size(line); } } @@ -851,23 +860,32 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, case BODY_CHUNK: { char line[30]; + apr_bucket_brigade *bb; + apr_size_t len = 30; - ctx->state = BODY_NONE; + bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); /* We need to read the CRLF after the chunk. */ - if ((rv = ap_getline(line, sizeof(line), f->r, 0)) < 0) { + rv = ap_get_brigade(f->next, bb, AP_MODE_GETLINE, + APR_BLOCK_READ, 0); + if (rv != APR_SUCCESS) { return rv; } + apr_brigade_cleanup(bb); /* Read the real chunk line. */ - if ((rv = ap_getline(line, sizeof(line), f->r, 0)) < 0) { + rv = ap_get_brigade(f->next, bb, AP_MODE_GETLINE, + APR_BLOCK_READ, 0); + + if (rv != APR_SUCCESS) { return rv; } - ctx->state = BODY_CHUNK; + apr_brigade_flatten(bb, line, &len); ctx->remaining = get_chunk_size(line); if (!ctx->remaining) { /* Handle trailers by calling ap_get_mime_headers again! */ + ctx->state = BODY_NONE; ap_get_mime_headers(f->r); e = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); -- 2.50.1