--------------------- PatchSet 1538 Date: 2005/08/19 23:16:24 Author: dwsquid Branch: squid3-icap Tag: (none) Log: ran astyle Members: src/http.cc:1.49.2.6->1.49.2.7 Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.6 retrieving revision 1.49.2.7 diff -u -r1.49.2.6 -r1.49.2.7 --- squid3/src/http.cc 19 Aug 2005 23:15:59 -0000 1.49.2.6 +++ squid3/src/http.cc 19 Aug 2005 23:16:24 -0000 1.49.2.7 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.6 2005/08/19 23:15:59 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.7 2005/08/19 23:16:24 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -106,9 +106,11 @@ httpState->request = NULL; httpState->orig_request = NULL; #if ICAP_CLIENT + cbdataReferenceDone(httpState->icap); delete httpState->icap; #endif + cbdataFree(httpState); } @@ -643,7 +645,7 @@ storeEntryReplaceObject (entry, reply); if (eof == 1) { - transactionComplete(); + transactionComplete(); } } @@ -775,8 +777,10 @@ */ #if ICAP_CLIENT + icap->startRespMod(this, request, reply); #else + storeEntryReplaceObject(entry, reply); /* Note storeEntryReplaceObject() consumes reply, so we cannot use it */ reply = NULL; @@ -786,6 +790,7 @@ if (eof == 1) { transactionComplete(); } + ctx_exit(ctx); } @@ -798,6 +803,7 @@ HttpStateData::haveParsedReplyHeaders() { Ctx ctx = ctx_enter(entry->mem_obj->url); + if (getReply()->sline.status == HTTP_PARTIAL_CONTENT && getReply()->content_range) currentOffset = getReply()->content_range->spec.offset; @@ -923,10 +929,12 @@ /* If we haven't seen the end of reply headers, we are not done */ debug(11,5)("persistentConnStatus: flags.headers_parsed=%d\n", flags.headers_parsed); + if (!flags.headers_parsed) return INCOMPLETE_MSG; clen = httpReplyBodySize(request->method, reply); + debug(11,5)("persistentConnStatus: clen=%d\n", clen); /* If there is no message body, we can be persistent */ @@ -940,9 +948,10 @@ /* If the body size is known, we must wait until we've gotten all of it. */ /* old technique: * if (entry->mem_obj->endOffset() < reply->content_length + reply->hdr_sz) */ - debug(11,5)("persistentConnStatus: body_bytes_read=%d, content_length=%d\n", - body_bytes_read, reply->content_length); - if (body_bytes_read < reply->content_length) + debug(11,5)("persistentConnStatus: body_bytes_read=%d, content_length=%d\n", + body_bytes_read, reply->content_length); + + if (body_bytes_read < reply->content_length) return INCOMPLETE_MSG; /* We got it all */ @@ -1065,10 +1074,10 @@ if (!flags.headers_parsed) /* - * When we called httpProcessReplyHeader() before, we - * didn't find the end of headers, but now we are - * definately at EOF, so we want to process the reply - * headers. + * When we called httpProcessReplyHeader() before, we + * didn't find the end of headers, but now we are + * definately at EOF, so we want to process the reply + * headers. */ processReplyHeader(buf, len); else if (getReply()->sline.status == HTTP_INVALID_HEADER && HttpVersion(0,9) != getReply()->sline.version) { @@ -1085,10 +1094,10 @@ err->request = requestLink((HttpRequest *) request); fwdFail(fwd, err); fwd->flags.dont_retry = 1; - flags.do_next_read = 0; - comm_close(fd); + flags.do_next_read = 0; + comm_close(fd); } else { - transactionComplete(); + transactionComplete(); } } } else { @@ -1149,23 +1158,27 @@ if (len > end) { #if ICAP_CLIENT - icap->sendMoreData (StoreIOBuffer(len - end, currentOffset, (char*)buf+end)); + icap->sendMoreData (StoreIOBuffer(len - end, currentOffset, (char*)buf+end)); #else + entry->write (StoreIOBuffer(len - end, currentOffset, (char*)buf+end)); currentOffset += (len - end); #endif - body_bytes_read += (len - end); + + body_bytes_read += (len - end); } flags.headers_pushed = 1; } else { #if ICAP_CLIENT - icap->sendMoreData (StoreIOBuffer(len, currentOffset, (char*)buf)); + icap->sendMoreData (StoreIOBuffer(len, currentOffset, (char*)buf)); #else + entry->write(StoreIOBuffer(len, currentOffset, (char*)buf)); currentOffset += len; #endif - body_bytes_read += len; + + body_bytes_read += len; } if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { @@ -1179,7 +1192,7 @@ switch (persistentConnStatus()) { case INCOMPLETE_MSG: - debug(11,5)("processReplyData: INCOMPLETE_MSG\n"); + debug(11,5)("processReplyData: INCOMPLETE_MSG\n"); /* Wait for more data or EOF condition */ if (flags.keepalive_broken) { @@ -1192,12 +1205,13 @@ break; case COMPLETE_PERSISTENT_MSG: - debug(11,5)("processReplyData: COMPLETE_PERSISTENT_MSG\n"); + debug(11,5)("processReplyData: COMPLETE_PERSISTENT_MSG\n"); /* yes we have to clear all these! */ commSetTimeout(fd, -1, NULL, NULL); flags.do_next_read = 0; comm_remove_close_handler(fd, httpStateFree, this); fwdUnregister(fd, fwd); + if (_peer) { if (_peer->options.originserver) pconnPush(fd, _peer->name, orig_request->port, orig_request->host); @@ -1206,13 +1220,14 @@ } else { pconnPush(fd, request->host, request->port, NULL); } - fd = -1; - transactionComplete(); + fd = -1; + + transactionComplete(); return; case COMPLETE_NONPERSISTENT_MSG: - debug(11,5)("processReplyData: COMPLETE_NONPERSISTENT_MSG\n"); + debug(11,5)("processReplyData: COMPLETE_NONPERSISTENT_MSG\n"); #if REALLY /* close the connection ourselves */ @@ -1222,15 +1237,18 @@ comm_remove_close_handler(fd, httpStateFree, this); fwdUnregister(fd, fwd); #if ICAP_CLIENT - icap->doneSending(); + + icap->doneSending(); #endif + fwdComplete(fwd); /* TODO: check that fd is still open here */ comm_close (fd); fd = -1; httpStateFree(fd, this); #endif - transactionComplete(); + + transactionComplete(); return; } @@ -1288,6 +1306,7 @@ comm_close(fd); return; } + #endif /* @@ -1313,17 +1332,22 @@ void HttpStateData::transactionComplete() { - if (fd >= 0) { - fwdUnregister(fd, fwd); - comm_remove_close_handler(fd, httpStateFree, this); - comm_close(fd); - fd = -1; - } + if (fd >= 0) { + fwdUnregister(fd, fwd); + comm_remove_close_handler(fd, httpStateFree, this); + comm_close(fd); + fd = -1; + } + #if ICAP_CLIENT - icap->doneSending(); + icap->doneSending(); + #else - fwdComplete(fwd); - httpStateFree(-1, this); + + fwdComplete(fwd); + + httpStateFree(-1, this); + #endif } @@ -2016,11 +2040,11 @@ void HttpStateData::takeAdaptedBody(MemBuf *buf) { - debug(11,5)("HttpStateData::takeAdaptedBody() called\n"); - debug(11,5)("\t%d bytes\n", buf->contentSize()); - debug(11,5)("\t%d is current offset\n", (int)currentOffset); - entry->write(StoreIOBuffer(buf, currentOffset)); - currentOffset += buf->contentSize(); + debug(11,5)("HttpStateData::takeAdaptedBody() called\n"); + debug(11,5)("\t%d bytes\n", buf->contentSize()); + debug(11,5)("\t%d is current offset\n", (int)currentOffset); + entry->write(StoreIOBuffer(buf, currentOffset)); + currentOffset += buf->contentSize(); } void