--------------------- PatchSet 5039 Date: 2002/09/18 22:17:07 Author: rbcollins Branch: fixrange Tag: (none) Log: extract duplicted read logic Members: src/client_side.c:1.72.2.31->1.72.2.32 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.31 retrieving revision 1.72.2.32 diff -u -r1.72.2.31 -r1.72.2.32 --- squid/src/client_side.c 18 Sep 2002 22:07:35 -0000 1.72.2.31 +++ squid/src/client_side.c 18 Sep 2002 22:17:07 -0000 1.72.2.32 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.31 2002/09/18 22:07:35 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.32 2002/09/18 22:17:07 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1275,29 +1275,24 @@ commSetTimeout(fd, Config.Timeout.lifetime, clientLifetimeTimeout, http); if (parser_return_code < 0) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; clientStreamNode *node = getTail (context); debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); clientSetReplyToError(node->data, ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, NULL, &conn->peer.sin_addr, NULL, conn->in.buf, NULL); - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(getTail (context), http, readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); safe_free(prefix); break; } if ((request = urlParse(method, http->uri)) == NULL) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; clientStreamNode *node = getTail (context); debug(33, 5) ("Invalid URL: %s\n", http->uri); clientSetReplyToError(node->data, ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, &conn->peer.sin_addr, NULL, NULL, NULL); - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(getTail (context), http, - readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); safe_free(prefix); break; } else { @@ -1337,27 +1332,21 @@ request->http_ver = http->http_ver; if (!urlCheckRequest(request) || httpHeaderHas(&request->header, HDR_TRANSFER_ENCODING)) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; clientStreamNode *node = getTail (context); clientSetReplyToError(node->data, ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED, request->method, NULL, &conn->peer.sin_addr, request, NULL, NULL); - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, - readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); break; } if (!clientIsContentLengthValid(request)) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; clientStreamNode *node = http->client_stream.tail->prev->data; clientSetReplyToError(node->data, ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED, request->method, NULL, &conn->peer.sin_addr, request, NULL, NULL); - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, - readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); break; } http->request = requestLink(request); @@ -1369,14 +1358,12 @@ /* Is it too large? */ if (!clientIsRequestBodyValid(request->content_length) || clientIsRequestBodyTooLargeForPolicy(request->content_length)) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; clientStreamNode *node = getTail (context); clientSetReplyToError(node->data, ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL, &conn->peer.sin_addr, http->request, NULL, NULL); - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(getTail (context), http, readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); break; } } @@ -1388,7 +1375,6 @@ * is happy with the input */ if (conn->in.offset >= Config.maxRequestHeaderSize) { - StoreIOBuffer readBuffer = EMPTYIOBUFFER; /* The request is too large to handle */ clientStreamNode *node; context = @@ -1405,9 +1391,8 @@ for (S = (clientSocketContext **) & conn->currentobject; *S; S = &(*S)->next); *S = context; - readBuffer.length = HTTP_REQBUF_SZ; - readBuffer.data = context->reqbuf; - clientStreamRead(getTail (context), context->http, readBuffer); + assert(context->http->out.offset == 0); + clientPullData (context); return; } break;