Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 80093 invoked by uid 500); 28 Dec 2000 01:14:24 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 80082 invoked by uid 500); 28 Dec 2000 01:14:24 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 28 Dec 2000 01:14:23 -0000 Message-ID: <20001228011423.80072.qmail@locus.apache.org> From: rbb@locus.apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/http http_protocol.c rbb 00/12/27 17:14:23 Modified: . CHANGES modules/http http_protocol.c Log: Ignore CRLF (or LF) when PEEK'ing at data on the socket. The general problem is that some browsers send an extra line at the end of a POST request. We use the PEEK method to determine if there is any data left on the socket, if there is then we delay sending the response until we have enough data to make it worthwhile. If the browser sends an extra blank line, we don't want to delay the response at all. The only time we use the PEEK method is to check for a second request, so this is safe to do. This also solves Joe Orton's problem of specifying a Content- Length of 1 for a blank line, and having the server wait to send back a response. The problem is that Linux (all Unix really) sends two characters \r\n for a blank line, so specifying a C-L of 1 means that the server still sees a \n when it PEEKs that the socket data. That \n can be safely ignored however. Revision Changes Path 1.27 +5 -0 httpd-2.0/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/httpd-2.0/CHANGES,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- CHANGES 2000/12/27 23:41:16 1.26 +++ CHANGES 2000/12/28 01:14:21 1.27 @@ -1,5 +1,10 @@ Changes with Apache 2.0b1 + *) Ignore \r\n or \n when using PEEK mode for input filters. The problem + is that some browsers send extra lines at the end of POST requests, and + we don't want to delay sending data back to the user just because the + browser isn't well behaved. [Ryan Bloom] + *) Get SuEXEC working again. We can't send absolute paths to suExec because it refuses to execute those programs. SuEXEC also wasn't always recognizing configuration changes made using the autoconf 1.261 +29 -20 httpd-2.0/modules/http/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v retrieving revision 1.260 retrieving revision 1.261 diff -u -r1.260 -r1.261 --- http_protocol.c 2000/12/21 21:09:56 1.260 +++ http_protocol.c 2000/12/28 01:14:22 1.261 @@ -969,28 +969,37 @@ const char *str; apr_size_t length; - if (AP_BRIGADE_EMPTY(ctx->b)) { - return APR_EOF; - } - - e = AP_BRIGADE_FIRST(ctx->b); - while (e->length == 0) { - AP_BUCKET_REMOVE(e); - ap_bucket_destroy(e); - - if (AP_BRIGADE_EMPTY(ctx->b)) { + /* The purpose of this loop is to ignore any CRLF (or LF) at the end + * of a request. Many browsers send extra lines at the end of POST + * requests. We use the PEEK method to determine if there is more + * data on the socket, so that we know if we should delay sending the + * end of one request until we have served the second request in a + * pipelined situation. We don't want to actually delay sending a + * response if the server finds a CRLF (or LF), becuause that doesn't + * mean that there is another request, just a blank line. + */ + while (1) { + if (AP_BRIGADE_EMPTY(ctx->b)) { e = NULL; - break; } - - e = AP_BRIGADE_FIRST(ctx->b); - } - - if (!e || ap_bucket_read(e, &str, &length, AP_NONBLOCK_READ) != APR_SUCCESS) { - return APR_EOF; - } - else { - return APR_SUCCESS; + else { + e = AP_BRIGADE_FIRST(ctx->b); + } + if (!e || ap_bucket_read(e, &str, &length, AP_NONBLOCK_READ) != APR_SUCCESS) { + return APR_EOF; + } + else { + const char *c = str; + while (c - str < length) { + if (*c == ASCII_LF) + c++; + else if (*c == ASCII_CR && *(c + 1) == ASCII_LF) + c += 2; + else return APR_SUCCESS; + } + AP_BUCKET_REMOVE(e); + ap_bucket_destroy(e); + } } }