--MimeMultipartBoundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This isn't much of a contribution, I'm afraid. I'm still getting to
grips with squid's internal structure..so this little addition is
only half a feature, at present.
A while ago, discussion on squid-users about 1.2 error messages
ranged back and forth. Some nominal percentage of cache administrators
wanted error messages generated by upstream caches to be replaced with
the custom ones supplied by squid 1.2. Essentially, they wanted to be
able to choose how error messages were presented to their users and
clients. A fair enough sort of thing, IMO.
Obviously, that isn't feasible for the current editions of
squid 1.1 or for any non-squid proxy at this stage. However, there's
no reason not to make it possible for 1.2, if it can signal that the
content is an error page, and of what nature.
This is a pretty meagre attempt on my part. I hope to do somewhat better
once I've gotten more familiar with the code. Nevertheless, it's a start
(and it works), and I always find that code speaks louder than good ideas.
So, the patch below introduces a new header field, added by
errorpage.c: 'X-Cache-Error'. Two datums are provided, the first being the
error page_id, and the other being xerrno. (I know xerrno isn't terribly
useful or portable. What I feel _really_ should be in there is all the
necessary info for a downstream cache to be able to produce it's own
error page, with substitutions based in the supplied data.
It's a start, at least)
So, the presence of X-Cache-Error in a reply, implies 'replaceable content',
that is, a recieving cache may replace the body with an error-page that it
generates itself. Or not. Probably there should be an option. I don't have
the code to do that (yet), but this is the first part...something potentially
useful, as well as a way for me to get to grips with squid 1.2's internal
structure.
Comments?
PS: 'make distclean' fails to delete the Makefile in snmplib
diff -rc squid-1.2.beta20/src/HttpHeader.c squid-1.2.beta20+cache_error/src/HttpHeader.c
*** squid-1.2.beta20/src/HttpHeader.c Thu Apr 23 02:23:41 1998
--- squid-1.2.beta20+cache_error/src/HttpHeader.c Sat May 16 20:47:25 1998
***************
*** 116,121 ****
--- 116,122 ----
{"WWW-Authenticate", HDR_WWW_AUTHENTICATE, ftStr},
{"X-Cache", HDR_X_CACHE, ftStr},
{"X-Cache-Lookup", HDR_X_CACHE_LOOKUP, ftStr},
+ {"X-Cache-Error", HDR_X_CACHE_ERROR, ftStr},
{"Other:", HDR_OTHER, ftStr} /* ':' will not allow matches */
};
static HttpHeaderFieldInfo *Headers = NULL;
***************
*** 151,157 ****
HDR_EXPIRES, HDR_LAST_MODIFIED, HDR_LOCATION, HDR_MAX_FORWARDS,
HDR_MIME_VERSION, HDR_PUBLIC, HDR_RETRY_AFTER, HDR_SERVER, HDR_SET_COOKIE,
HDR_UPGRADE, HDR_WARNING, HDR_PROXY_CONNECTION, HDR_X_CACHE,
! HDR_X_CACHE_LOOKUP, HDR_OTHER
};
static HttpHeaderMask RequestHeadersMask; /* set run-time using RequestHeaders */
--- 152,158 ----
HDR_EXPIRES, HDR_LAST_MODIFIED, HDR_LOCATION, HDR_MAX_FORWARDS,
HDR_MIME_VERSION, HDR_PUBLIC, HDR_RETRY_AFTER, HDR_SERVER, HDR_SET_COOKIE,
HDR_UPGRADE, HDR_WARNING, HDR_PROXY_CONNECTION, HDR_X_CACHE,
! HDR_X_CACHE_LOOKUP, HDR_X_CACHE_ERROR, HDR_OTHER
};
static HttpHeaderMask RequestHeadersMask; /* set run-time using RequestHeaders */
diff -rc squid-1.2.beta20/src/enums.h squid-1.2.beta20+cache_error/src/enums.h
*** squid-1.2.beta20/src/enums.h Fri Apr 24 17:09:33 1998
--- squid-1.2.beta20+cache_error/src/enums.h Sat May 16 23:39:45 1998
***************
*** 218,223 ****
--- 218,224 ----
HDR_WWW_AUTHENTICATE,
HDR_X_CACHE,
HDR_X_CACHE_LOOKUP, /* tmp hack, remove later */
+ HDR_X_CACHE_ERROR,
HDR_PROXY_CONNECTION,
HDR_OTHER,
HDR_ENUM_END
diff -rc squid-1.2.beta20/src/errorpage.c squid-1.2.beta20+cache_error/src/errorpage.c
*** squid-1.2.beta20/src/errorpage.c Fri Apr 24 14:52:07 1998
--- squid-1.2.beta20+cache_error/src/errorpage.c Sun May 17 00:19:06 1998
***************
*** 496,505 ****
--- 496,513 ----
HttpReply *
errorBuildReply(ErrorState * err)
{
+ char details[CVT_BUF_SZ];
HttpReply *rep = httpReplyCreate();
MemBuf content = errorBuildContent(err);
/* no LMT for error pages; error pages expire immediately */
httpReplySetHeaders(rep, 1.0, err->http_status, NULL, "text/html", content.size, 0, squid_curtime);
+ /* include some information for downstream caches. Implicit replaceable content */
+ /* This isn't quite sufficient. xerrno is not necessarily meaningful to another */
+ /* system, so we really should expand it. Additionally, we should identify */
+ /* ourselves. Someone might want to know. Someone _will_ want to know */
+ /* OTOH, the first X-CACHE-MISS entry should tell us who. */
+ snprintf(details,CVT_BUF_SZ,"%d %d",err->page_id,err->xerrno);
+ httpHeaderPutStr(&rep->header,HDR_X_CACHE_ERROR,details);
httpBodySet(&rep->body, content.buf, content.size + 1, NULL);
memBufClean(&content);
return rep;
--MimeMultipartBoundary--
Received on Tue Jul 29 2003 - 13:15:49 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:47 MST