]> granicus.if.org Git - apache/commitdiff
Clean up the end-of-headers detection code a bit. I'm still getting some
authorGarrett Rooney <rooneg@apache.org>
Tue, 24 Jan 2006 06:21:09 +0000 (06:21 +0000)
committerGarrett Rooney <rooneg@apache.org>
Tue, 24 Jan 2006 06:21:09 +0000 (06:21 +0000)
strange problems with really large numbers of headers, but I'm starting to
suspect that it's a problem with my FastCGI lib, not this module, and this
at least makes things shorter and a bit easier to read, along with fixing
one bug.

* modules/proxy/mod_proxy_fcgi.c
  (handle_headers): Get rid of some cases that were not strictly needed.
   Insert a case that was missed that screwed things up when there were
   more than one header.
  (dispatch): Move the 'done with headers' code into the preceding block,
   add a note about a case that needs to be investigated.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/fcgi-proxy-dev@371840 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_fcgi.c

index f796301fd0af2e156aed8c887b1f81cb867d9bf9..172f6f9fdf281caf95ff34b5d5d900bc56bb032b 100644 (file)
@@ -354,25 +354,17 @@ static int handle_headers(request_rec *r,
     while (*itr) {
         if (*itr == '\r') {
             switch (*state) {
-                case HDR_STATE_READING_HEADERS:
-                    *state = HDR_STATE_GOT_CR;
-                    break;
-
                 case HDR_STATE_GOT_CRLF:
                     *state = HDR_STATE_GOT_CRLFCR;
                     break;
 
                 default:
-                    *state = HDR_STATE_READING_HEADERS;
+                    *state = HDR_STATE_GOT_CR;
                     break;
             }
         }
         else if (*itr == '\n') {
             switch (*state) {
-                 case HDR_STATE_READING_HEADERS:
-                     *state = HDR_STATE_GOT_LF;
-                     break;
-
                  case HDR_STATE_GOT_LF:
                      *state = HDR_STATE_DONE_WITH_HEADERS;
                      break;
@@ -386,10 +378,13 @@ static int handle_headers(request_rec *r,
                      break;
 
                  default:
-                     *state = HDR_STATE_READING_HEADERS;
+                     *state = HDR_STATE_GOT_LF;
                      break;
             }
         }
+        else {
+            *state = HDR_STATE_READING_HEADERS;
+        }
 
         if (*state == HDR_STATE_DONE_WITH_HEADERS)
             break;
@@ -669,26 +664,26 @@ recv_again:
 
                         if (st == 1) {
                             seen_end_of_headers = 1;
+
+                            rv = ap_pass_brigade(r->output_filters, ob);
+                            if (rv != APR_SUCCESS) {
+                                break;
+                            }
+
+                            apr_brigade_cleanup(ob);
+
+                            apr_pool_clear(pfb->scratch_pool);
                         }
                         else if (st == -1) {
                             rv = APR_EINVAL;
                             break;
                         }
-                    }
-
-                    if (seen_end_of_headers) {
-                        rv = ap_pass_brigade(r->output_filters, ob);
-                        if (rv != APR_SUCCESS) {
-                            break;
+                        else {
+                            /* We're still looking for the end of the
+                             * headers, so this part of the data will need
+                             * to persist. */
+                            apr_bucket_setaside(b, pfb->scratch_pool);
                         }
-
-                        apr_brigade_cleanup(ob);
-
-                        apr_pool_clear(pfb->scratch_pool);
-                    } else {
-                        /* We're still looking for the end of the headers,
-                         * so this part of the data will need to persist. */
-                        apr_bucket_setaside(b, pfb->scratch_pool);
                     }
 
                     /* If we didn't read all the data go back and get the
@@ -698,6 +693,8 @@ recv_again:
                         goto recv_again;
                     }
                 } else {
+                    /* XXX what if we haven't seen end of the headers yet? */
+
                     b = apr_bucket_eos_create(c->bucket_alloc);
 
                     APR_BRIGADE_INSERT_TAIL(ob, b);