--------------------- PatchSet 4675 Date: 2002/08/14 14:45:50 Author: rbcollins Branch: esi Tag: (none) Log: yet another checkpoint in error recoding - nearly done Members: src/client_side_reply.c:1.1.2.5->1.1.2.6 Index: squid/src/client_side_reply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_reply.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/client_side_reply.c 14 Aug 2002 14:18:31 -0000 1.1.2.5 +++ squid/src/client_side_reply.c 14 Aug 2002 14:45:50 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.1.2.5 2002/08/14 14:18:31 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.1.2.6 2002/08/14 14:45:50 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -106,6 +106,7 @@ } assert (errstate->callback_data == NULL); errorAppendEntry (context->http->entry, errstate); + /* Now the caller reads to get this */ } static void clientProcessExpired(clientReplyContext *context) @@ -162,7 +163,7 @@ HTTP_REQBUF_SZ, http->reqbuf, clientHandleIMSReply, - http); + context); } int @@ -291,7 +292,7 @@ HTTP_REQBUF_SZ - http->reqofs, http->reqbuf + http->reqofs, clientHandleIMSReply, - http); + context); return; } } else if (clientGetsOldEntry(entry, http->old_entry, http->request)) { @@ -513,6 +514,7 @@ http->log_type = LOG_TCP_IMS_HIT; clientSendMoreData(context, buf, size); } else { + clientStreamNode *next; time_t timestamp = e->timestamp; MemBuf mb = httpPacked304Reply(e->mem_obj->reply); http->log_type = LOG_TCP_IMS_HIT; @@ -530,6 +532,15 @@ storeAppend(e, mb.buf, mb.size); memBufClean(&mb); storeComplete(e); + /* TODO: why put this in the store and then serialise it and then parse it again. + * Simply mark the request complete in our context and + * write the reply struct to the client side + */ + /* now write this back to the requester */ + + next = http->stream_head.head->next->data; + storeClientCopy(http->sc, e, next->readoff, next->readlen, next->readbuf, + clientSendMoreData, context); } } else { /* @@ -582,30 +593,41 @@ * Deny loops when running in accelerator/transproxy mode. */ if (http->flags.accel && r->flags.loopdetect) { + clientStreamNode *next; http->al.http.code = HTTP_FORBIDDEN; err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, &http->conn->peer.sin_addr, http->request); http->entry = clientCreateStoreEntry(context, r->method, null_request_flags); errorAppendEntry(http->entry, err); + /* and trigger a read of the resulting object */ + next = http->stream_head.head->next->data; + storeClientCopy(http->sc, http->entry, next->readoff, next->readlen, next->readbuf, + clientSendMoreData, context); return; - } - assert(http->out.offset == 0); - http->entry = clientCreateStoreEntry(context, r->method, r->flags); - if (http->redirect.status) { - HttpReply *rep = httpReplyCreate(); + } else { + clientStreamNode *next; + assert(http->out.offset == 0); + http->entry = clientCreateStoreEntry(context, r->method, r->flags); + /* And trigger a read of the resultant object */ + next = http->stream_head.head->next->data; + storeClientCopy(http->sc, http->entry, next->readoff, next->readlen, next->readbuf, + clientSendMoreData, context); + if (http->redirect.status) { + HttpReply *rep = httpReplyCreate(); #if LOG_TCP_REDIRECTS - http->log_type = LOG_TCP_REDIRECT; + http->log_type = LOG_TCP_REDIRECT; #endif - storeReleaseRequest(http->entry); - httpRedirectReply(rep, http->redirect.status, http->redirect.location); - httpReplySwapOut(rep, http->entry); - httpReplyDestroy(rep); - storeComplete(http->entry); - return; + storeReleaseRequest(http->entry); + httpRedirectReply(rep, http->redirect.status, http->redirect.location); + httpReplySwapOut(rep, http->entry); + httpReplyDestroy(rep); + storeComplete(http->entry); + return; + } + if (http->flags.internal) + r->protocol = PROTO_INTERNAL; + fwdStart(http->conn ? http->conn->fd : -1, http->entry, r); } - if (http->flags.internal) - r->protocol = PROTO_INTERNAL; - fwdStart(http->conn ? http->conn->fd : -1, http->entry, r); } /* @@ -1281,6 +1303,7 @@ /* wait for more to arrive */ http->reqofs += retsize; assert(http->reqofs <= HTTP_REQBUF_SZ); + /* TODO: copy into the supplied buffer */ storeClientCopy(http->sc, entry, http->out.offset + http->reqofs, HTTP_REQBUF_SZ - http->reqofs, @@ -1308,6 +1331,7 @@ } } assert(rep || (body_buf && body_size)); + /* TODO: move the data in the buffer back by the request header size */ clientStreamCallback (http->stream_head.head->data, http, rep, body_buf, body_size); }