Commit 6c81db01 authored by Garrett Rooney's avatar Garrett Rooney
Browse files

Clean up the end-of-headers detection code a bit. I'm still getting some

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
parent 0e694d29
Loading
Loading
Loading
Loading
+21 −24
Original line number Diff line number Diff line
@@ -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,14 +664,7 @@ recv_again:

                        if (st == 1) {
                            seen_end_of_headers = 1;
                        }
                        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;
@@ -685,11 +673,18 @@ recv_again:
                            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. */
                        }
                        else if (st == -1) {
                            rv = APR_EINVAL;
                            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);
                        }
                    }

                    /* If we didn't read all the data go back and get the
                     * rest of it. */
@@ -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);