On 21/03/2013 3:09 p.m., Amos Jeffries wrote:
On 21/03/2013 1:34 p.m., Alex Rousskov wrote:
On 03/20/2013 05:40 PM, Amos Jeffries wrote:
The Key: header being proposed for standardization replaces and extends
the Vary header to provide more fine-grained variant selection by
caches.
The attached patch add the Key: header on Squid generated error
pages so
that any receiving clients which support the new header are able to use
it for handling our error pages.
This also serves as a implementation example for how origin servers can
easily implement Key headers alongside Vary headers during the upgrade
transition period.
see http://tools.ietf.org/html/draft-fielding-http-key-02 for the
current specification.
+ // Key:Accept-Language;b="foo"
+ tmp.append(";b=\"");
+ tmp.append(err_language);
+ tmp.append('"');
This will assert when err_language is nil (which happens to be the case
in the build I just tested).
"Doh!" seems to be the word. Revised patch attached.
Amos
=== modified file 'src/errorpage.cc'
--- src/errorpage.cc 2013-03-17 12:19:16 +0000
+++ src/errorpage.cc 2013-03-21 02:33:29 +0000
@@ -1192,15 +1192,30 @@
#if USE_ERR_LOCALES
/*
- * If error page auto-negotiate is enabled in any way, send the Vary.
+ * If error page auto-negotiate is enabled in any way, send the Vary
and Key
* RFC 2616 section 13.6 and 14.44 says MAY and SHOULD do this.
* We have even better reasons though:
* see http://wiki.squid-cache.org/KnowledgeBase/VaryNotCaching
*/
if (!Config.errorDirectory) {
/* We 'negotiated' this ONLY from the Accept-Language. */
+ String tmp = "Accept-Language";
+
+ // Vary:Accept-Language
rep->header.delById(HDR_VARY);
- rep->header.putStr(HDR_VARY, "Accept-Language");
+ rep->header.putStr(HDR_VARY,tmp.termedBuf());
+
+ // Key:Accept-Language;b="foo"
+ // Only supply the match parameters if the language is actually
found.
+ // On the generic reply to all 'unknown' inputs we must be vague
like Vary
+ // which makes the recipient use the entire Accept-Language as the
variant key.
+ if (err_language) {
+ tmp.append(";b=\"");
+ tmp.append(err_language);
+ tmp.append('"');
+ }
+ rep->header.delById(HDR_KEY);
+ rep->header.putStr(HDR_KEY, tmp.termedBuf());
}
/* add the Content-Language header according to RFC section 14.12 */