]> granicus.if.org Git - apache/commitdiff
Improve comments for reviewers to understand this logic
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Aug 2016 21:38:12 +0000 (21:38 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Aug 2016 21:38:12 +0000 (21:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755115 13f79535-47bb-0310-9956-ffa450edef68

server/protocol.c

index 443416f8ae30c2810efa47598b3fa22dc79b4b00..9bc0083100c95d26218a74d49418a45d40e67c71 100644 (file)
@@ -840,7 +840,7 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
             if (last_field == NULL) {
                 r->status = HTTP_BAD_REQUEST;
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(03442)
-                              "Line folding encounterd before first"
+                              "Line folding encountered before first"
                               " header line");
                 return;
             }
@@ -891,10 +891,14 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
                 last_field[last_len] = ' ';
             }
             last_len += len;
+
+            /* The obs-fold continuation line is merged to the last_field
+             * so continue to the next input line
+             */
             continue;
         }
 
-        /* not a continuation line */
+        /* Not a continuation line, so process the last_field fully composed */
 
         if (r->server->limit_req_fields
                 && (++fields_read > r->server->limit_req_fields)) {
@@ -1005,24 +1009,18 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
 
         apr_table_addn(r->headers_in, last_field, value);
 
-        /* reset the alloc_len so that we'll allocate a new
-         * buffer if we have to do any more folding: we can't
-         * use the previous buffer because its contents are
-         * now part of r->headers_in
+        /* After recording the last_field header line, we end our read loop
+         * here upon encountering the trailing line terminating headers
          */
-        alloc_len = 0;
-
-        /* end of logic where current line was not a continuation line */
-
-        /* Found a blank line, stop. */
         if (len == 0) {
             break;
         }
 
-        /* Keep track of this line so that we can parse it on
-         * the next loop iteration.  (In the folded case, last_field
-         * has been updated already.)
+        /* Keep track of this new header line (not an obs-fold). We will merge
+         * subsequent obs_fold lines on the next loop iterations. The zero
+         * alloc_len signals we have not allocated an obs-folding buffer yet
          */
+        alloc_len = 0;
         last_field = field;
         last_len = len;
     }