--------------------- PatchSet 4720 Date: 2002/08/20 12:35:42 Author: rbcollins Branch: esi Tag: (none) Log: send surrogate capability header, beginning of surrogate control logic Members: src/ESI.c:1.1.2.19->1.1.2.20 src/client_side_reply.c:1.1.2.16->1.1.2.17 src/http.c:1.21->1.21.2.1 Index: squid/src/ESI.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ESI.c,v retrieving revision 1.1.2.19 retrieving revision 1.1.2.20 diff -u -r1.1.2.19 -r1.1.2.20 --- squid/src/ESI.c 20 Aug 2002 12:16:16 -0000 1.1.2.19 +++ squid/src/ESI.c 20 Aug 2002 12:35:42 -0000 1.1.2.20 @@ -1,6 +1,6 @@ /* - * $Id: ESI.c,v 1.1.2.19 2002/08/20 12:16:16 rbcollins Exp $ + * $Id: ESI.c,v 1.1.2.20 2002/08/20 12:35:42 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -1750,8 +1750,6 @@ if (!stream) return; httpHeaderInit (&tempheaders, hoRequest); - /* TODO: move this to clientRequestBegin as part of loosely coupled header set */ - httpHeaderPutStr (&tempheaders, HDR_SURROGATE_CAPABILITY, "Surrogate/1.0"); /* Ensure variable state is clean */ assert (vars->output == NULL); 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.16 retrieving revision 1.1.2.17 diff -u -r1.1.2.16 -r1.1.2.17 --- squid/src/client_side_reply.c 19 Aug 2002 11:42:57 -0000 1.1.2.16 +++ squid/src/client_side_reply.c 20 Aug 2002 12:35:45 -0000 1.1.2.17 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.1.2.16 2002/08/19 11:42:57 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.1.2.17 2002/08/20 12:35:45 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1284,6 +1284,16 @@ } } +/* TODO: implement surrogate targeting and control processing */ +/* TODO: move to esi source file. */ +static int +esiEnableProcessing (HttpReply *rep); +int +esiEnableProcessing (HttpReply *rep) { + if (httpHeaderHas(&rep->header, HDR_SURROGATE_CONTROL)) + return 1; + return 0; +} /* * accepts chunk of a http message in buf, parses prefix, filters headers and @@ -1418,7 +1428,8 @@ } /* ESI TODO: replace me with a true ESI header check */ if (http->flags.accel && rep->sline.status != HTTP_FORBIDDEN && - !clientAlwaysAllowResponse(rep->sline.status) && !strcmp (http->uri, "http://192.168.0.2:9673/esi_page_1.html?foobar=foo")) { + !clientAlwaysAllowResponse(rep->sline.status) && + esiEnableProcessing(rep)) { debug(88, 0) ("Enabling ESI processing for %s\n", http->uri); clientStreamInsertHead (&http->client_stream, esiStreamRead, esiProcessStream, esiStreamStatus,NULL); Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -r1.21 -r1.21.2.1 --- squid/src/http.c 7 Jun 2002 22:43:02 -0000 1.21 +++ squid/src/http.c 20 Aug 2002 12:35:45 -0000 1.21.2.1 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.21 2002/06/07 22:43:02 squidadm Exp $ + * $Id: http.c,v 1.21.2.1 2002/08/20 12:35:45 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -819,6 +819,15 @@ httpHeaderPutStr(hdr_out, HDR_VIA, strBuf(strVia)); stringClean(&strVia); + /* ESI TODO: conditionally enable this */ + /* Append Surrogate-Capabilities */ + strVia = httpHeaderGetList(hdr_in, HDR_SURROGATE_CAPABILITY); + snprintf(bbuf, BBUF_SZ, "%s=Surrogate/1.0 ESI/1.0", + ThisCache); + strListAdd(&strVia, bbuf, ','); + httpHeaderPutStr(hdr_out, HDR_SURROGATE_CAPABILITY, strBuf(strVia)); + stringClean(&strVia); + /* append X-Forwarded-For */ strFwd = httpHeaderGetList(hdr_in, HDR_X_FORWARDED_FOR); strListAdd(&strFwd, (cfd < 0 ? "unknown" : fd_table[cfd].ipaddr), ',');