--------------------- PatchSet 4674 Date: 2002/08/14 14:18:29 Author: rbcollins Branch: esi Tag: (none) Log: yet another checkpoint in error recoding Members: src/ESI.c:1.1.2.4->1.1.2.5 src/client_side.c:1.65.2.7->1.65.2.8 src/client_side_reply.c:1.1.2.4->1.1.2.5 src/client_side_request.c:1.1.2.4->1.1.2.5 src/protos.h:1.59.2.4->1.59.2.5 Index: squid/src/ESI.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ESI.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/ESI.c 14 Aug 2002 11:16:05 -0000 1.1.2.4 +++ squid/src/ESI.c 14 Aug 2002 14:18:29 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: ESI.c,v 1.1.2.4 2002/08/14 11:16:05 rbcollins Exp $ + * $Id: ESI.c,v 1.1.2.5 2002/08/14 14:18:29 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -445,6 +445,9 @@ return rv; } +extern ErrorState *clientBuildError (err_type, http_status, char const *, struct in_addr *, request_t *); + + void esiFail (esiContext *context, clientHttpRequest *http) { ErrorState *err; Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.65.2.7 retrieving revision 1.65.2.8 diff -u -r1.65.2.7 -r1.65.2.8 --- squid/src/client_side.c 14 Aug 2002 12:53:22 -0000 1.65.2.7 +++ squid/src/client_side.c 14 Aug 2002 14:18:30 -0000 1.65.2.8 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.65.2.7 2002/08/14 12:53:22 rbcollins Exp $ + * $Id: client_side.c,v 1.65.2.8 2002/08/14 14:18:30 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -144,15 +144,6 @@ static int clientRequestBodyTooLarge(int clen); static void clientProcessBody(ConnStateData * conn); -/* Move to protos.h - it's used anywhere on the request pipeline, before - * any reply data flows - */ -void -clientSetReplyToError (void *data, - err_type err, http_status status, method_t method, char const *uri, - struct in_addr *addr, request_t *failedrequest, char *unparsedrequest) -; - #if USE_IDENT static void clientIdentDone(const char *ident, void *data) @@ -1137,7 +1128,7 @@ 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, conn->in.buf, NULL); clientStreamRead (http->stream_head.tail->data, http, 0, HTTP_REQBUF_SZ, http->reqbuf); @@ -1149,7 +1140,7 @@ 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); + &conn->peer.sin_addr, NULL, NULL, NULL); clientStreamRead (http->stream_head.tail->data, http, 0, HTTP_REQBUF_SZ, http->reqbuf); @@ -1193,7 +1184,7 @@ httpHeaderHas(&request->header, HDR_TRANSFER_ENCODING)) { clientStreamNode *node = http->stream_head.tail->prev->data; clientSetReplyToError (node->data,ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED, request->method, - NULL, &conn->peer.sin_addr, request, NULL); + NULL, &conn->peer.sin_addr, request, NULL, NULL); clientStreamRead (http->stream_head.tail->data, http, 0, HTTP_REQBUF_SZ, http->reqbuf); @@ -1202,7 +1193,7 @@ if (!clientCheckContentLength(request)) { clientStreamNode *node = http->stream_head.tail->prev->data; clientSetReplyToError (node->data,ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED, request->method, - NULL, &conn->peer.sin_addr, request, NULL); + NULL, &conn->peer.sin_addr, request, NULL, NULL); clientStreamRead (http->stream_head.tail->data, http, 0,HTTP_REQBUF_SZ,http->reqbuf); break; } @@ -1216,7 +1207,7 @@ if (clientRequestBodyTooLarge(request->content_length)) { clientStreamNode *node = http->stream_head.tail->prev->data; clientSetReplyToError (node->data,ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE,METHOD_NONE, NULL, - &conn->peer.sin_addr, http->request, NULL); + &conn->peer.sin_addr, http->request, NULL, NULL); clientStreamRead (http->stream_head.tail->data, http, 0,HTTP_REQBUF_SZ,http->reqbuf); break; } @@ -1238,7 +1229,7 @@ debug(33, 1) ("Config 'request_header_max_size'= %ld bytes.\n", (long int) Config.maxRequestHeaderSize); clientSetReplyToError (node->data,ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE,METHOD_NONE, NULL, - &conn->peer.sin_addr, NULL, NULL); + &conn->peer.sin_addr, NULL, NULL, NULL); /* add to the client request queue */ for (H = &conn->chr; *H; H = &(*H)->next); *H = http; @@ -1397,7 +1388,7 @@ clientHttpRequest *http = parseHttpRequestAbort(conn, "error:Connection%20lifetime%20expired"); node = http->stream_head.tail->prev->data; clientSetReplyToError (node->data,ERR_LIFETIME_EXP, HTTP_REQUEST_TIMEOUT,METHOD_NONE, "N/A", - &conn->peer.sin_addr, NULL, NULL); + &conn->peer.sin_addr, NULL, NULL, NULL); /* No requests can be outstanded */ assert(conn->chr == NULL); /* add to the client request queue */ 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.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/client_side_reply.c 14 Aug 2002 11:42:52 -0000 1.1.2.4 +++ squid/src/client_side_reply.c 14 Aug 2002 14:18:31 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.1.2.4 2002/08/14 11:42:52 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.1.2.5 2002/08/14 14:18:31 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -59,6 +59,7 @@ static STCB clientHandleIMSReply; static int modifiedSince(StoreEntry *, request_t *); static log_type clientIdentifyStoreObject(clientHttpRequest * http); +extern ErrorState *clientBuildError (err_type, http_status, char const *, struct in_addr *, request_t *); /* The clientReply clean interface */ /* privates */ @@ -81,14 +82,12 @@ return context; } -void clientSetReplyToError (void *,err_type,http_status,method_t,char const *,struct in_addr *, request_t *, char *); - - /* create an error in the store awaiting the client side to read it. */ void clientSetReplyToError (void *data, err_type err, http_status status, method_t method, char const *uri, - struct in_addr *addr, request_t *failedrequest, char *unparsedrequest) + struct in_addr *addr, request_t *failedrequest, char *unparsedrequest, + auth_user_request_t *auth_user_request) { clientReplyContext *context = data; ErrorState *errstate = clientBuildError(err, status, uri, addr, failedrequest); @@ -101,6 +100,11 @@ context->http->al.http.code = errstate->http_status; context->http->entry = clientCreateStoreEntry(context, method, null_request_flags); + if (auth_user_request) { + errstate->auth_user_request = auth_user_request; + authenticateAuthUserRequestLock (errstate->auth_user_request); + } + assert (errstate->callback_data == NULL); errorAppendEntry (context->http->entry, errstate); } static void @@ -1371,3 +1375,15 @@ return e; } +ErrorState * +clientBuildError (err_type page_id, http_status status, char const *url, struct in_addr *src_addr, request_t *request) +{ + ErrorState *err = errorCon(page_id, status); + err->src_addr = *src_addr; + if (url) + err->url = xstrdup (url); + if (request) + err->request = requestLink (request); + return err; +} + Index: squid/src/client_side_request.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_request.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/client_side_request.c 14 Aug 2002 11:16:06 -0000 1.1.2.4 +++ squid/src/client_side_request.c 14 Aug 2002 14:18:31 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.c,v 1.1.2.4 2002/08/14 11:16:06 rbcollins Exp $ + * $Id: client_side_request.c,v 1.1.2.5 2002/08/14 14:18:31 rbcollins Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originall Duane Wessels in client_side.c) @@ -62,6 +62,9 @@ extern CSR clientGetMoreData; /* Create a request and kick it off */ +/* TODO: Pass in the buffers to be used in the inital Read request, + * as they are determined by the user + */ int /* returns nonzero on failure */ clientBeginRequest (method_t method, char const *url, CSCB *streamcallback, void *streamdata, HttpHeader const *header) { @@ -184,7 +187,6 @@ clientHttpRequest *http = data; err_type page_id; http_status status; - ErrorState *err = NULL; char *proxy_auth_msg = NULL; debug(85, 2) ("The request %s %s is %s, because it matched '%s'\n", RequestMethodStr[http->request->method], http->uri, @@ -213,8 +215,6 @@ */ page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName); http->log_type = LOG_TCP_DENIED; - http->entry = clientCreateStoreEntry(node->data, http->request->method, - null_request_flags); if (answer == ACCESS_REQ_PROXY_AUTH || aclIsProxyAuth(AclMatchedName)) { if (!http->flags.accel) { /* Proxy authorisation needed */ @@ -230,16 +230,11 @@ if (page_id == ERR_NONE) page_id = ERR_ACCESS_DENIED; } - err = clientBuildError (page_id, status, NULL, http->conn ? &http->conn->peer.sin_addr : &no_addr, http->request); - if (http->conn && http->conn->auth_user_request) - err->auth_user_request = http->conn->auth_user_request; - else if (http->request->auth_user_request) - err->auth_user_request = http->request->auth_user_request; - /* lock for the error state */ - if (err->auth_user_request) - authenticateAuthUserRequestLock(err->auth_user_request); - err->callback_data = NULL; - errorAppendEntry(http->entry, err); + clientSetReplyToError (node->data,page_id, status, http->request->method, NULL, + http->conn ? &http->conn->peer.sin_addr : &no_addr, http->request, NULL, + http->conn && http->conn->auth_user_request ? + http->conn->auth_user_request : http->request->auth_user_request); + clientStreamRead (http->stream_head.tail->data, http, 0,HTTP_REQBUF_SZ,http->reqbuf); } } @@ -546,16 +541,3 @@ clientStreamRead (http->stream_head.tail->data, http, 0, HTTP_REQBUF_SZ, http->reqbuf); } - -/* Widely used utility functions */ -ErrorState * -clientBuildError (err_type page_id, http_status status, char const *url, struct in_addr *src_addr, request_t *request) -{ - ErrorState *err = errorCon(page_id, status); - err->src_addr = *src_addr; - if (url) - err->url = xstrdup (url); - if (request) - err->request = requestLink (request); - return err; -} Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.59.2.4 retrieving revision 1.59.2.5 diff -u -r1.59.2.4 -r1.59.2.5 --- squid/src/protos.h 14 Aug 2002 11:16:06 -0000 1.59.2.4 +++ squid/src/protos.h 14 Aug 2002 14:18:31 -0000 1.59.2.5 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.59.2.4 2002/08/14 11:16:06 rbcollins Exp $ + * $Id: protos.h,v 1.59.2.5 2002/08/14 14:18:31 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -149,14 +149,15 @@ extern void httpRequestFree (void *); /* client_side_request.c - client side request related routines (pure logic) */ -extern int clientDetermineActionAfterWrite(int fd, clientHttpRequest const *http, StoreEntry *entry, size_t size); -extern STCB clientSendMoreData; -extern ErrorState *clientBuildError (err_type, http_status, char const *, struct in_addr *, request_t *); extern int clientBeginRequest (method_t, char const *, CSCB *, void *, HttpHeader const *); /* client_side_reply.c - client side reply related routines (pure logic, no comms) */ extern int clientCheckTransferDone(clientHttpRequest const *); extern void *clientReplyNewContext (clientHttpRequest *); +extern int clientDetermineActionAfterWrite(int fd, clientHttpRequest const *http, StoreEntry *entry, size_t size); +extern STCB clientSendMoreData; +extern void clientSetReplyToError (void *,err_type,http_status,method_t,char const *,struct in_addr *, request_t *, char *,auth_user_request_t *auth_user_request); + /* clientStream.c */ extern void clientStreamInit (dlink_list *, CSR *, void *, CSCB *, void *);