--------------------- PatchSet 5799 Date: 2003/06/27 01:05:34 Author: hno Branch: icap-2_5 Tag: (none) Log: Rewrite of how icap replaces the original request in REQMOD to now mess up the request structures. It is better to just create a new request structure and copy over what is needed than to try to patch up the original request structure. Members: src/icap.c:1.1.16.5->1.1.16.6 Index: squid/src/icap.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap.c,v retrieving revision 1.1.16.5 retrieving revision 1.1.16.6 diff -u -r1.1.16.5 -r1.1.16.6 --- squid/src/icap.c 3 Jun 2003 16:10:57 -0000 1.1.16.5 +++ squid/src/icap.c 27 Jun 2003 01:05:34 -0000 1.1.16.6 @@ -1,5 +1,5 @@ /* - * $Id: icap.c,v 1.1.16.5 2003/06/03 16:10:57 hno Exp $ + * $Id: icap.c,v 1.1.16.6 2003/06/27 01:05:34 hno Exp $ * This file has the ICAP client code... * * Author: Geetha Manjunath, @@ -242,10 +242,11 @@ icapReqModReadReplyDone(ConnStateData *connState, clientHttpRequest *http, void *data) { HttpStateData *httpState = data; - request_t *hreq; + request_t *new_req; + request_t *old_req; + + new_req = requestLink(http->request); - /* Now download the modified request just read */ - if (http) { /* Unlink the request from our faked connState */ { clientHttpRequest **H; @@ -255,43 +256,46 @@ connState->nrequests--; assert(!connState->nrequests); } + assert(connState->nrequests == 0); + assert(connState->chr == NULL); - /* XXX This is very broken. - * - Who frees the clientHttpRequest *http? - * - Cannot overwrite httpState->orig_request fields blindly like this - * - httpState->request needs to be freed - */ + /* XXX - Who frees the clientHttpRequest *http now that it is unlinked? */ - hreq = http->request; - /* - if ( ! (httpState->fwd->servers && httpState->fwd->servers->code == DIRECT)) - stringReset(&(hreq->urlpath), http->uri); - */ - httpState->request = requestLink(hreq); - connState->nrequests = 0; - connState->chr = NULL; - if (strcmp(httpState->orig_request->host, httpState->request->host)) { - if (httpState->fwd->servers && httpState->fwd->servers->code == DIRECT) { - /* Direct connection to internet! */ - httpState->fwd->request = requestLink(hreq); - httpState->fwd->server_fd = -1; - fwdConnectStart(httpState->fwd); - httpState->fd = httpState->fwd->server_fd; - comm_add_close_handler(httpState->fd, httpStateFree, httpState); + old_req = requestLink(httpState->orig_request); + requestUnlink(httpState->orig_request); + requestUnlink(httpState->request); + + /* Fix up the new request to match the original request */ + new_req->class = old_req->class; + new_req->flags = old_req->flags; + new_req->body_connection = old_req->body_connection; + old_req->body_connection = NULL; + + /* XXX: Probably need to copy some stuff from the old_req to new_req */ + + /* Switch to the new request */ + httpState->orig_request = requestLink(new_req); + if (httpState->peer) { + request_t *proxy_req; + proxy_req = requestCreate(new_req->method, + PROTO_NONE, storeUrl(httpState->entry)); + xstrncpy(proxy_req->host, httpState->peer->host, SQUIDHOSTNAMELEN); + proxy_req->port = httpState->peer->http_port; + proxy_req->flags = new_req->flags; + proxy_req->lastmod = new_req->lastmod; + httpState->request = requestLink(proxy_req); } else { - stringReset(&(hreq->urlpath), http->uri); - } - /* Change orig request's host too : See httpBuildRequestHeader - puts default Host header from orig_request */ - strcpy(httpState->orig_request->host, httpState->request->host); + httpState->request = requestLink(new_req); } - httpState->orig_request->port = httpState->request->port; - /** GEETHA: Added this to fix bugs related to header modifying reqmod filters. */ - httpState->orig_request->header = httpState->request->header; - httpSendRequest(httpState); - } + /* cleanup */ + requestUnlink(old_req); + requestUnlink(new_req); icapStateFree(httpState->icap); httpState->icap = NULL; + + /* fire off the request */ + httpSendRequest(httpState); return 1; } @@ -1099,6 +1103,11 @@ if (Config.icapcfg.send_client_ip) { memBufPrintf(mb, "X-Client-IP: %s\r\n", client_addr); } +#if NOT_YET_FINISHED + if (Config.icapcfg.trailers) { + memBufPrintf(mb, "X-TE: trailers\r\n"); + } +#endif } /*