--------------------- PatchSet 8550 Date: 2006/08/25 09:24:11 Author: adri Branch: parserwork Tag: (none) Log: Oops, up until now the header parsing has been performed with a rather invalid buffer.. how stupid of me. Anyway. This code removes the need for the separate 'prefix' buffer. The existing code was already reworked to use the HttpMsgBuf struct which had 'buf' already pointing to the incoming conn buffer. This just saves on the malloc/copy/free overhead a little. Members: src/client_side.c:1.143.2.6->1.143.2.7 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.143.2.6 retrieving revision 1.143.2.7 diff -u -r1.143.2.6 -r1.143.2.7 --- squid/src/client_side.c 25 Aug 2006 09:12:40 -0000 1.143.2.6 +++ squid/src/client_side.c 25 Aug 2006 09:24:11 -0000 1.143.2.7 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.143.2.6 2006/08/25 09:12:40 adri Exp $ + * $Id: client_side.c,v 1.143.2.7 2006/08/25 09:24:11 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -118,7 +118,7 @@ static void clientProcessMiss(clientHttpRequest *); static void clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep); static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static clientHttpRequest *parseHttpRequest(ConnStateData *, HttpMsgBuf *, method_t *, int *, char **, size_t *); +static clientHttpRequest *parseHttpRequest(ConnStateData *, HttpMsgBuf *, method_t *, int *, size_t *); static void clientRedirectStart(clientHttpRequest * http); static RH clientRedirectDone; static void clientCheckNoCache(clientHttpRequest *); @@ -3486,8 +3486,8 @@ * isn't fulfilled. */ static clientHttpRequest * -parseHttpRequest(ConnStateData * conn, HttpMsgBuf *hmsg, method_t * method_p, int *status, - char **prefix_p, size_t * req_line_sz_p) +parseHttpRequest(ConnStateData * conn, HttpMsgBuf *hmsg, method_t * method_p, + int *status, size_t * req_line_sz_p) { char *inbuf = NULL; char *mstr = NULL; @@ -3506,7 +3506,6 @@ int r; /* pre-set these values to make aborting simpler */ - *prefix_p = NULL; *method_p = METHOD_NONE; *status = -1; @@ -3632,12 +3631,9 @@ http->start = current_time; http->req_sz = prefix_sz; http->range_iter.boundary = StringNull; - *prefix_p = xmalloc(prefix_sz + 1); - xmemcpy(*prefix_p, hmsg->buf, prefix_sz); - *(*prefix_p + prefix_sz) = '\0'; dlinkAdd(http, &http->active, &ClientActiveRequests); - debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); + //debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); #if THIS_VIOLATES_HTTP_SPECS_ON_URL_TRANSFORMATION if ((t = strchr(url, '#'))) /* remove HTML anchors */ @@ -3814,10 +3810,9 @@ http = parseHttpRequest(conn, &hmsg, &method, &parser_return_code, - &prefix, &req_line_sz); if (!http) - safe_free(prefix); + (void) 0; if (http) { /* @@ -3851,7 +3846,6 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); return 0; } if ((request = urlParse(method, http->uri)) == NULL) { @@ -3863,14 +3857,13 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); return 0; } /* compile headers */ /* we should skip request line! */ if ((http->http_ver.major >= 1) && !httpRequestParseHeader(request, &hmsg)) { - debug(33, 1) ("Failed to parse request headers: %s\n%s\n", - http->uri, prefix); + debug(33, 1) ("Failed to parse request headers: %s\n", + http->uri); err = errorCon(ERR_INVALID_URL, HTTP_BAD_REQUEST); err->src_addr = conn->peer.sin_addr; err->url = xstrdup(http->uri); @@ -3879,10 +3872,8 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); return 0; } - safe_free(prefix); safe_free(http->log_uri); http->log_uri = xstrdup(urlCanonicalClean(request)); if (!http->flags.internal && internalCheck(strBuf(request->urlpath))) {