From: Garrett Rooney Date: Tue, 24 Jan 2006 06:21:09 +0000 (+0000) Subject: Clean up the end-of-headers detection code a bit. I'm still getting some X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c198ffb7a0f09d9b1334526d2ee7712d5046457e;p=apache 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 --- diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c index f796301fd0..172f6f9fdf 100644 --- a/modules/proxy/mod_proxy_fcgi.c +++ b/modules/proxy/mod_proxy_fcgi.c @@ -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);