-- Forwarded to squid-dev since I do not maintain Squid source code.
Squid-dev folks will guide you from there if they care to review
your patch...
-- Please note that your code will match "x-private" or any other
extension-token with "private" substring, which is probably not
good. Also, the code will not match "PRIVATE" while tokens are,
IRRC, case-insensitive according to RFC 2616. I thought that
Squid parses and recognized Cache-Control tokens so that you
do not have to fiddle with raw headers, but I may be missing
your objective here.
On Sat, 11 Aug 2001, Krasi Zlatev wrote:
>
> Hi,
> I hope you will look at the code I am sending you and let me know if it
> is ok!
>
> I would really appreciate it, as I don't know if I wrote it entirely OK
> and especially as to memory management.
>
> Thank you!
>
> The idea is to remove from the header the word 'private', so objects with
> Cache-Control: private will be cached.It seems to work, as they are
> cached and I haven't expreienced any problems the past week I run squid
> like that. But I think that the squid process is a bit bigger than it was
> before that, that is why I'd like for you to tell me If this code is OK.
>
> I am using 2.2.STABLE5.
> I have added this in http.c in the function httpProcessReplyHeader
>
> -- start here ---
>
> const char *str_search = "private";
> const char *str_replace = " ";
>
> char *new_text, *p;
> int offset;
> int len_new, len_text, len_search, len_replace;
>
> aclCheck_t ch;
> memset(&ch, '\0', sizeof(ch));
> ch.request = httpState->request;
>
> ..................................
>
>
> if (strstr(httpState->reply_hdr, "Cache-Control") && strstr(httpState->reply_hdr, "private")) {
> if (Config.accessList.overrideCacheControlPrivate)
> {
> if (aclCheckFast(Config.accessList.overrideCacheControlPrivate, &ch))
> {
> debug(11, 1) ("override_cache_control_private is matched by [%s]\n", httpState->entry->mem_obj->url);
> debug(11, 1) ("Changing the header for [%s]\n", httpState->entry->mem_obj->url);
>
> len_text = strlen(httpState->reply_hdr);
> len_search = strlen(str_search);
> len_replace = strlen(str_replace);
> len_new = len_text - len_search;
> len_new += len_replace;
> new_text = memAllocate(MEM_8K_BUF);
> if(p = strstr( httpState->reply_hdr, str_search )) {
> offset = p - httpState->reply_hdr;
> strncpy( new_text, httpState->reply_hdr, offset );
> *(new_text + offset) = '\0';
> strcat(new_text, str_replace);
> p += len_search;
> strcat(new_text, p);
>
> if (httpState->reply_hdr) {
> memFree(httpState->reply_hdr, MEM_8K_BUF);
> httpState->reply_hdr = NULL;
> }
>
> if (httpState->reply_hdr == NULL)
> httpState->reply_hdr = memAllocate(MEM_8K_BUF);
>
> memcpy(httpState->reply_hdr, new_text, len_new);
>
> }
>
> if (new_text) {
> memFree(new_text, MEM_8K_BUF);
> new_text = NULL;
> }
>
> }
> }
> }
>
> --- end here ---
>
>
> Krasi Zlatev
> +395 (32) 944 138
> Network Administration
> EWeb
> Enjoy!
>
>
>
>
>
>
Received on Sat Aug 11 2001 - 11:10:19 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:10 MST