From: wessels <> Date: Tue, 28 Apr 1998 01:54:01 +0000 (+0000) Subject: Ignore leading whitespace when looking for requests and server replies, X-Git-Tag: SQUID_3_0_PRE1~3404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ede6c8f55181af670fde110e9f262beea2e4ee3;p=thirdparty%2Fsquid.git Ignore leading whitespace when looking for requests and server replies, to make HTTP a bit more robust. Don't bail out if we receive a empty line where a request-line is expected (a SHOULD in rfc2068). --- diff --git a/src/client_side.cc b/src/client_side.cc index 4bbf00a4eb..5f55fa94c4 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.293 1998/04/24 23:47:38 wessels Exp $ + * $Id: client_side.cc,v 1.294 1998/04/27 19:55:10 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1938,6 +1938,11 @@ clientReadRequest(int fd, void *data) size = 0; } conn->in.offset += size; + /* Skip leading (and trailing) whitespace */ + while (conn->in.offset > 0 && isspace(conn->in.buf[0])) { + xmemmove(conn->in.buf, conn->in.buf + 1, conn->in.offset - 1); + conn->in.offset--; + } conn->in.buf[conn->in.offset] = '\0'; /* Terminate the string */ while (conn->in.offset > 0) { int nrequests; diff --git a/src/http.cc b/src/http.cc index 7366c5b128..4f2abee76e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.266 1998/04/27 19:52:48 wessels Exp $ + * $Id: http.cc,v 1.267 1998/04/27 19:54:01 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -458,6 +458,16 @@ httpReadReply(int fd, void *data) clen >>= 1; IOStats.Http.read_hist[bin]++; } + if (!httpState->reply_hdr && len > 0) { + /* Skip whitespace */ + while (len > 0 && isspace(*buf)) + xmemmove(buf, buf + 1, len--); + if (len == 0) { + /* Continue to read... */ + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + return; + } + } if (len < 0) { debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n", fd, xstrerror());