]> granicus.if.org Git - apache/commitdiff
Switch ap_http_filter to use ap_get_brigade and apr_brigade_flatten
authorJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 18 Apr 2002 22:50:54 +0000 (22:50 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 18 Apr 2002 22:50:54 +0000 (22:50 +0000)
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

index 6c87ae867aea1e885809f1e631ba59e80f34d5da..331a4a55f9577d8a72207bb78cc25f7c3bec7b79 100644 (file)
@@ -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);