--------------------- PatchSet 10358 Date: 2008/01/03 13:26:45 Author: adri Branch: s27_adri Tag: (none) Log: Remove buf/size and reference the buf directly; this is the last step before moving to buffer referencing. Members: src/http.c:1.63.2.3.4.29->1.63.2.3.4.30 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.29 retrieving revision 1.63.2.3.4.30 diff -u -r1.63.2.3.4.29 -r1.63.2.3.4.30 --- squid/src/http.c 29 Dec 2007 13:39:42 -0000 1.63.2.3.4.29 +++ squid/src/http.c 3 Jan 2008 13:26:45 -0000 1.63.2.3.4.30 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.29 2007/12/29 13:39:42 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.30 2008/01/03 13:26:45 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -431,26 +431,17 @@ size_t hdr_size; HttpReply *reply = entry->mem_obj->reply; Ctx ctx = ctx_enter(entry->mem_obj->url); - const char *buf = NULL; - int size = 0; - - if (b) { - buf = buf_buf(b) + parse_start; - size = buf_len(b) - parse_start; - } - - assert(size >= 0); debug(11, 3) ("httpProcessReplyHeader: key '%s'\n", storeKeyText(entry->hash.key)); - debug(11, 2) ("httpProcessReplyHeaderBlock: FD %d: given %d byets to look at\n", httpState->fd, size); + debug(11, 2) ("httpProcessReplyHeaderBlock: FD %d: given %d byets to look at\n", httpState->fd, buf_len(b) - parse_start); assert(httpState->reply_hdr_state == 0); - hdr_len = size; + hdr_len = buf_len(b) - parse_start; - if (hdr_len > 4 && strncmp(buf, "HTTP/", 5)) { - debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%.*s'\n", size, buf); + if (hdr_len > 4 && strncmp(buf_buf(b) + parse_start, "HTTP/", 5)) { + debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%.*s'\n", buf_len(b) - parse_start, buf_buf(b) + parse_start); httpState->reply_hdr_state += 2; httpState->chunk_size = -1; /* Terminated by EOF */ // XXX how am I meant to handle a non-compliant header? Just bomb the rest of the request? @@ -460,16 +451,16 @@ ctx_exit(ctx); return 0; } - hdr_size = headersEnd(buf, hdr_len); + hdr_size = headersEnd(buf_buf(b) + parse_start, hdr_len); if (hdr_size) hdr_len = hdr_size; if (hdr_len > Config.maxReplyHeaderSize) { debug(11, 1) ("httpProcessReplyHeader: Too large reply header\n"); - storeAppend(entry, buf, size); + storeAppend(entry, buf_buf(b) + parse_start, buf_len(b) - parse_start); reply->sline.status = HTTP_HEADER_TOO_LARGE; httpState->reply_hdr_state += 2; ctx_exit(ctx); - return size; + return buf_len(b) - parse_start; } /* headers can be incomplete only if object still arriving */ if (!hdr_size) { @@ -477,7 +468,7 @@ hdr_size = hdr_len; else { ctx_exit(ctx); - return size; /* headers not complete */ + return buf_len(b) - parse_start; /* headers not complete */ } } stringClean(&entry->mem_obj->vary_headers); @@ -486,24 +477,24 @@ assert(httpState->reply_hdr_state == 1); httpState->reply_hdr_state++; debug(11, 9) ("GOT HTTP REPLY HDR:\n---------\n%.*s\n----------\n", - (int) hdr_size, buf); + (int) hdr_size, buf_buf(b) + parse_start); /* Parse headers into reply structure */ /* what happens if we fail to parse here? */ - httpReplyParse(reply, buf, hdr_size); + httpReplyParse(reply, buf_buf(b) + parse_start, hdr_size); /* Skip 1xx messages for now. Advertised in Via as an internal 1.0 hop */ if (reply->sline.status >= 100 && reply->sline.status < 200) { httpReplyReset(reply); httpState->reply_hdr_state = 0; ctx_exit(ctx); - if (hdr_size < size) + if (hdr_size < (buf_len(b) - parse_start)) return hdr_size + httpProcessReplyHeaderBlock(httpState, b, hdr_size); else return hdr_size; } - storeAppend(entry, buf, hdr_size); + storeAppend(entry, buf_buf(b) + parse_start, hdr_size); if (reply->sline.status >= HTTP_INVALID_HEADER) { - debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%.*s'\n", (int) hdr_size, buf); + debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%.*s'\n", (int) hdr_size, buf_buf(b) + parse_start); ctx_exit(ctx); return hdr_size; } @@ -592,7 +583,7 @@ if (Config.onoff.detect_broken_server_pconns && httpReplyBodySize(httpState->request->method, reply) == -1) { debug(11, 1) ("httpProcessReplyHeader: Impossible keep-alive header from '%s'\n", storeUrl(entry)); debug(11, 2) ("GOT HTTP REPLY HDR:\n---------\n%.*s\n----------\n", - (int) hdr_size, buf); + (int) hdr_size, buf_buf(b) + parse_start); httpState->flags.keepalive_broken = 1; } }