Revision: 14412
Author: adrian.chadd
Date: Tue Feb 16 20:08:37 2010
Log: Fix Issue 24 - storeurl rewrite with redirected content.

There's an odd issue with certain cachable redirects where the url is
rewritten via storeurl where the sent URL and the received URL match.
This forms a redirect loop.

This patch breaks the redirect loop.

Reference:

* http://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube/Discussion
* Issue 24
* Issue 27


http://code.google.com/p/lusca-cache/source/detail?r=14412

Modified:
 /branches/LUSCA_HEAD/src/client_side.c

=======================================
--- /branches/LUSCA_HEAD/src/client_side.c      Sat Feb 13 23:34:59 2010
+++ /branches/LUSCA_HEAD/src/client_side.c      Tue Feb 16 20:08:37 2010
@@ -1536,6 +1536,26 @@
                is_modified = 0;
        }
     }
+
+    /*
+ * There's the possibility that a cached redirect will refer to the same URL + * in some circumstances where the request URL is being rewritten (eg storeurl)
+     * where the redirect is not explicitly as uncachable.
+     * Deny looping here and do not cache the response.
+     */
+
+    /*
+ * XXX strcmp() sucks but the strings are both C strings. Look at String'ifying it
+     * XXX soon!
+     */
+ if (mem->reply->sline.status >= 300 && mem->reply->sline.status < 400) { + if (!strcmp(http->uri, httpHeaderGetStr(&e->mem_obj->reply->header, HDR_LOCATION))) { + debug(33, 1) ("clientCacheHit: Redirect Loop Detected: %s\n",http->uri);
+           http->log_type = LOG_TCP_MISS;
+           clientProcessMiss(http);
+           return;
+        }
+    }
     stale = refreshCheckHTTPStale(e, r);
debug(33, 2) ("clientCacheHit: refreshCheckHTTPStale returned %d\n", stale);
     if (stale == 0) {

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to