Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 49790 invoked by uid 500); 18 Oct 2000 23:22:58 -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 49756 invoked by uid 500); 18 Oct 2000 23:22:52 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 18 Oct 2000 23:22:48 -0000 Message-ID: <20001018232248.49581.qmail@locus.apache.org> From: gregames@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/main http_protocol.c gregames 00/10/18 16:22:46 Modified: src CHANGES src/main http_protocol.c Log: Support HTTP header line folding with input filtering. Some funkyness remains with Win32 telnet doing folding - that can wait til tomorrow. Revision Changes Path 1.288 +3 -0 apache-2.0/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-2.0/src/CHANGES,v retrieving revision 1.287 retrieving revision 1.288 diff -u -r1.287 -r1.288 --- CHANGES 2000/10/18 22:24:34 1.287 +++ CHANGES 2000/10/18 23:22:38 1.288 @@ -1,4 +1,7 @@ Changes with Apache 2.0a8 + *) Support HTTP header line folding with input filtering. + [Greg Ames] + *) Mod_include works again. This should still be re-written, but at least now we can serve an SHTML page again. [Ryan Bloom] 1.191 +32 -18 apache-2.0/src/main/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- http_protocol.c 2000/10/18 19:32:30 1.190 +++ http_protocol.c 2000/10/18 23:22:41 1.191 @@ -1039,18 +1039,23 @@ const char *temp; int retval; int total = 0; + int looking_ahead = 0; apr_ssize_t length; conn_rec *c = r->connection; + core_request_config *req_cfg; ap_bucket_brigade *b; ap_bucket *e; - b = ap_brigade_create(c->pool); + req_cfg = (core_request_config *) + ap_get_module_config(r->request_config, &core_module); + b = req_cfg->bb; + /* make sure it's empty unless we're folding */ + AP_DEBUG_ASSERT(fold || AP_BRIGADE_EMPTY(b)); while (1) { if (AP_BRIGADE_EMPTY(b)) { if (ap_get_brigade(c->input_filters, b, AP_GET_LINE) != APR_SUCCESS || AP_BRIGADE_EMPTY(b)) { - ap_brigade_destroy(b); return -1; } } @@ -1067,6 +1072,12 @@ break; } + if ((looking_ahead) && (*temp != ' ') && (*temp != '\t')) { + /* just checking, but can't fold because next line isn't + * indented + */ + break; + } last_char = pos + length - 1; if (last_char < beyond_buff) { memcpy(pos, temp, length); @@ -1075,21 +1086,16 @@ } else { /* input line was larger than the caller's buffer */ - AP_BUCKET_REMOVE(e); - ap_bucket_destroy(e); - ap_brigade_destroy(b); + ap_brigade_destroy(b); + + /* don't need to worry about req_cfg->bb being bogus. + * the request is about to die, and ErrorDocument + * redirects get a new req_cfg->bb + */ + return -1; } -/**** XXX - * Check for folding - * Continue appending if line folding is desired and - * the last line was not empty and we have room in the buffer and - * the next line begins with a continuation character. - * if (!fold || (retval == 0) && (n > 1) - * && (retval = e->read(e, ) - * && ((next == ' ') || (next == '\t'))); - */ pos = last_char; /* Point at the last character */ if (*pos == '\n') { /* Did we get a full line of input? */ @@ -1109,17 +1115,25 @@ --pos; /* trim extra trailing spaces or tabs */ } *pos = '\0'; /* zap end of string */ - total = pos - s; - break; + + /* look ahead another line if line folding is desired + * and the last line wasn't empty + */ + looking_ahead = (fold && ((pos - s) > total)); + total = pos - s; /* update total string length */ + if (!looking_ahead) { + AP_DEBUG_ASSERT(AP_BRIGADE_EMPTY(b)); + break; /* normal loop exit */ + } } else { - /* bump past last character read, + /* no LF yet...keep going + * bump past last character read, * and set total in case we bail before finding a LF */ total = ++pos - s; } } - ap_brigade_destroy(b); return total; }