--------------------- PatchSet 10417 Date: 2008/01/20 01:22:28 Author: adri Branch: s27_adri Tag: (none) Log: Include a starting offset in the http message parsing code. Members: src/HttpMsg.c:1.12.12.2->1.12.12.3 src/client_side.c:1.202.2.9.4.42->1.202.2.9.4.43 src/protos.h:1.146.2.4.4.38->1.146.2.4.4.39 src/structs.h:1.158.2.5.4.17->1.158.2.5.4.18 Index: squid/src/HttpMsg.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpMsg.c,v retrieving revision 1.12.12.2 retrieving revision 1.12.12.3 diff -u -r1.12.12.2 -r1.12.12.3 --- squid/src/HttpMsg.c 22 Dec 2007 14:32:11 -0000 1.12.12.2 +++ squid/src/HttpMsg.c 20 Jan 2008 01:22:28 -0000 1.12.12.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.c,v 1.12.12.2 2007/12/22 14:32:11 adri Exp $ + * $Id: HttpMsg.c,v 1.12.12.3 2008/01/20 01:22:28 adri Exp $ * * DEBUG: section 74 HTTP Message * AUTHOR: Alex Rousskov @@ -128,12 +128,13 @@ /* Adrian's replacement message buffer code to parse the request/reply line */ void -HttpMsgBufInit(HttpMsgBuf * hmsg, const char *buf, size_t size) +HttpMsgBufInit(HttpMsgBuf * hmsg, const char *buf, int offset, size_t size) { hmsg->buf = buf; hmsg->size = size; hmsg->req_start = hmsg->req_end = -1; hmsg->h_start = hmsg->h_end = -1; + hmsg->offset = offset; hmsg->r_len = hmsg->u_len = hmsg->m_len = hmsg->v_len = hmsg->h_len = 0; } @@ -167,14 +168,14 @@ const char *t; /* Find \r\n - end of URL+Version (and the request) */ - t = memchr(hmsg->buf, '\n', hmsg->size); + t = memchr(hmsg->buf + hmsg->offset, '\n', hmsg->size); if (!t) { retcode = 0; goto finish; } /* XXX this should point to the -end- of the \r\n, \n, etc. */ hmsg->req_end = t - hmsg->buf; - i = 0; + i = hmsg->offset; /* Find first non-whitespace - beginning of method */ for (; i < hmsg->req_end && (xisspace(hmsg->buf[i])); i++); @@ -317,7 +318,7 @@ int httpMsgFindHeadersEnd(HttpMsgBuf * hmsg) { - int e = 0; + int e = hmsg->offset; int state = 1; const char *mime = hmsg->buf; int l = hmsg->size; Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.42 retrieving revision 1.202.2.9.4.43 diff -u -r1.202.2.9.4.42 -r1.202.2.9.4.43 --- squid/src/client_side.c 20 Jan 2008 00:39:49 -0000 1.202.2.9.4.42 +++ squid/src/client_side.c 20 Jan 2008 01:22:29 -0000 1.202.2.9.4.43 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.42 2008/01/20 00:39:49 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.43 2008/01/20 01:22:29 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -4023,7 +4023,7 @@ *chttp = NULL; *cbytes = 0; - HttpMsgBufInit(&msg, buf, len); + HttpMsgBufInit(&msg, buf, 0, len); /* Limit the number of concurrent requests to 2 */ for (n = conn->reqs.head, nrequests = 0; n; n = n->next, nrequests++); if (nrequests >= (Config.onoff.pipeline_prefetch ? 2 : 1)) { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.38 retrieving revision 1.146.2.4.4.39 diff -u -r1.146.2.4.4.38 -r1.146.2.4.4.39 --- squid/src/protos.h 15 Jan 2008 14:36:45 -0000 1.146.2.4.4.38 +++ squid/src/protos.h 20 Jan 2008 01:22:29 -0000 1.146.2.4.4.39 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.38 2008/01/15 14:36:45 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.39 2008/01/20 01:22:29 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1407,7 +1407,7 @@ vary_id_t storeAddVary(const char *url, const method_t method, const cache_key * key, String *etag, String *vary, String *vary_headers, String *accept_encoding); /* New HTTP message parsing support */ -extern void HttpMsgBufInit(HttpMsgBuf * hmsg, const char *buf, size_t size); +extern void HttpMsgBufInit(HttpMsgBuf * hmsg, const char *buf, int offset, size_t size); extern void httpMsgBufDone(HttpMsgBuf * hmsg); extern int httpMsgParseRequestLine(HttpMsgBuf * hmsg); extern int httpMsgParseRequestHeader(request_t * req, HttpMsgBuf * hmsg); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.158.2.5.4.17 retrieving revision 1.158.2.5.4.18 diff -u -r1.158.2.5.4.17 -r1.158.2.5.4.18 --- squid/src/structs.h 19 Jan 2008 16:35:29 -0000 1.158.2.5.4.17 +++ squid/src/structs.h 20 Jan 2008 01:22:29 -0000 1.158.2.5.4.18 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.158.2.5.4.17 2008/01/19 16:35:29 adri Exp $ + * $Id: structs.h,v 1.158.2.5.4.18 2008/01/20 01:22:29 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2489,8 +2489,11 @@ }; struct _HttpMsgBuf { + buf_t *nb; const char *buf; - size_t size; + int size; /* size of buffer */ + int offset; /* offset inside buffer to begin parsing */ + /* offset of first/last byte of headers */ int h_start, h_end, h_len; /* offset of first/last byte of request, including any padding */