[Varnish] #494: When backend server continues a header line with \n\t rather than \r\n\t remove only removes first line of header

Varnish varnish-bugs at projects.linpro.no
Thu Apr 23 19:38:26 CEST 2009


#494: When backend server continues a header line with \n\t rather than \r\n\t
remove only removes first line of header
----------------------+-----------------------------------------------------
 Reporter:  lrowe     |       Owner:  phk
     Type:  defect    |      Status:  new
 Priority:  normal    |   Milestone:     
Component:  varnishd  |     Version:  2.0
 Severity:  normal    |    Keywords:     
----------------------+-----------------------------------------------------
 This seems to be the result of a bug in Zope 2.10.7 that has been fixed in
 svn.

 The headers from Zope look like thisL
 {{{
 $ curl --header "Accept-Encoding: gzip" --include
 http://127.0.0.1:8080/www/qt-in-use
 HTTP/1.1 200 OK
 Server: Zope/(Zope 2.10.7-final, python 2.4.6, darwin) ZServer/1.1
 Plone/3.2.2
 Date: Thu, 23 Apr 2009 17:31:18 GMT
 Content-Length: 7375
 Content-Language: en
 Content-Encoding: gzip
 Expires: Mon, 26 Apr 1999 17:31:17 GMT
 Vary: Accept-Encoding,
         Accept-Encoding
 Last-Modified: Tue, 10 Mar 2009 13:17:11 GMT
 X-Caching-Rule-Id: plone-content-types
 Cache-Control: max-age=0, s-maxage=86400, must-revalidate, proxy-
 revalidate
 Content-Type: text/html;charset=utf-8
 X-Header-Set-Id: cache-in-proxy-24-hours
 Set-Cookie: I18N_LANGUAGE="en"; Path=/

 }}}

 Note that Vary here is "Accept-Encoding,\n\tAccept-Encoding"

 The headers from Varnish look like this:
 {{{
 $ curl --header "Accept-Encoding: gzip" --include  http://127.0.0.1:8000
 /qt-in-use
 HTTP/1.1 200 OK
 Server: Zope/(Zope 2.10.7-final, python 2.4.6, darwin) ZServer/1.1
 Plone/3.2.2
 Content-Language: en
 Content-Encoding: gzip
         Accept-Encoding
 Last-Modified: Tue, 10 Mar 2009 13:17:11 GMT
 X-Caching-Rule-Id: plone-content-types
 Content-Type: text/html;charset=utf-8
 X-Header-Set-Id: cache-in-proxy-24-hours
 Content-Length: 7367
 Vary: Accept-Encoding,Accept-Language
 Date: Thu, 23 Apr 2009 17:33:32 GMT
 X-Varnish: 192199513 192199510
 Via: 1.1 varnish
 Connection: keep-alive
 X-Varnish-Age: 1679
 Age: 0
 Cache-Control: max-age=300, s-maxage=0, must-revalidate, proxy-revalidate

 }}}

 VCL:
 {{{
 backend default {
   .host = "127.0.0.1";
   .port = "8080";
 }

 # Do NOT add localhost to the purce acl list
 # All requests to varnish from external users
 # will appear from localhost (from nginx and haproxy).
 acl purge {

   "localhost";
 }

 sub vcl_recv {
   # This url will always reply 200 whenever varnish is running
   if (req.request == "GET" && req.url ~ "/varnish-ping") {
     error 200 "OK";
   }
   # XXX for local testing
   set req.url = "/VirtualHostBase/http/127.0.0.1:8000/www/VirtualHostRoot"
 req.url;

   # Instead of lookup do purge_url to be sure we purge all the different
 varys
   if (req.request == "PURGE") {
     if (!client.ip ~ purge) {
       error 405 "Not allowed.";
     }
     purge_url(req.url);
     error 200 "Purged";
   }

   #
   # Normalize Accept headers, to vary on Accept-Encoding,Accept-Language
   #
   if (req.http.Accept-Encoding) {
     if (req.url ~ "\.(jpg|png|gif|swf|pdf|gz|tgz|bz2|tbz|zip)$" || req.url
 ~ "/image_[^/]*$") {
       # No point in compressing these
       remove req.http.Accept-Encoding;
     } elsif (req.http.Accept-Encoding ~ "gzip") {
       set req.http.Accept-Encoding = "gzip";
     } else {
       remove req.http.Accept-Encoding;
     }
   }
   # We only care about the language in the I18N_LANGUAGE cookie
   if (req.http.Cookie ~ "(^|.*; )I18N_LANGUAGE=") {
     set req.http.Accept-Language = regsub(req.http.Cookie, "(^|.*;
 )I18N_LANGUAGE=([^;]*)(; .*|$)", "\2");
     # XXX need to work out the proper way to match " here, e.g. "en"
     set req.http.Accept-Language = regsub(req.http.Accept-Language,
 "^.(.*).$", "\1");
   } else {
     set req.http.Accept-Language = "en";
   }

   #
   # Normalize Cookies
   #
   if (req.http.Cookie) {
     set req.http.X-Original-Cookie = req.http.Cookie;
     # Removing cookies from certain file types
     if (req.request == "GET" &&
         (req.url ~ "\.(gif|jpg|swf|css|js|png|pdf)$" || req.url ~
 "/image_[^/]*$")) {
       remove req.http.Cookie;
     } else {
       # Simplify tokenization
       set req.http.Cookie = "; " req.http.Cookie;
       # Remove I18N_LANGUAGE, osas and google analytics cookies
       set req.http.Cookie = regsuball(req.http.Cookie, ";
 (I18N_LANGUAGE|osas_id|__utm.)=[^;]*", "");
       # Finally remove cookie header if it is now empty
       if (!req.http.Cookie ~ "[^ ;]") {
         remove req.http.Cookie;
       } else {
         # Remove the leading delimiter
         set req.http.Cookie = regsub(req.http.Cookie, "^; ", "");
       }
     }
   }

   set req.grace = 360s;
 }

 sub restore_language {
   # Put back the I18N_LANGUAGE cookie we removed earlier (%22 is ")
   if (req.http.Cookie) {
     set bereq.http.Cookie = req.http.Cookie "; I18N_LANGUAGE=%22" req.http
 .Accept-Language "%22";
   } else {
     set bereq.http.Cookie = "I18N_LANGUAGE=%22" req.http.Accept-Language
 "%22";
   }
 }

 sub vcl_miss {
   call restore_language;
 }

 sub vcl_pass {
   call restore_language;
 }

 sub vcl_hit {
 }

 sub vcl_fetch {
   # Ref. #22479
   if (obj.status == 302 && obj.http.Location ~
 "^http://www.qtsoftware.com/acl_users") {
     set obj.http.X-Accel-Redirect = "/error404";
     set obj.status = 200;
     remove obj.http.Location;
     deliver;
   }

   # Removing cookies from certain file types
   if (req.request == "GET" &&
       (req.url ~ "\.(gif|jpg|swf|css|js|png|pdf)$" || req.url ~
 "/image_[^/]*$")) {
     remove obj.http.set-cookie;
   } elsif (obj.http.Vary || obj.http.X-Header-Set-Id == "cache-hack-
 for-24-hours") {
     # There is some weirdness deep in ZPublisher that needs working around
     set obj.http.Vary = "Accept-Encoding,Accept-Language";
   }

   set req.grace = 360s;

 #  # Disable client side caching
 #  set obj.http.cache-control = "max-age=0, s-maxage=0, must-revalidate";
 }

 sub vcl_deliver {
   if (resp.http.Age) {
     # By definition we have a fresh object
     set resp.http.X-Varnish-Age = resp.http.Age;
     set resp.http.Age = "0";
   }

   # rewrite s-maxage so intermediary proxies don't use it
   if (resp.http.Cache-Control ~ "s-maxage") {
     set resp.http.Cache-Control = regsub(resp.http.Cache-Control,
 "s-maxage=[0-9]+", "s-maxage=0");
   }
   # rewrite maxage we at least cache for 5 minutes
   if (resp.http.Cache-Control ~ "max-age=0") {
     set resp.http.Cache-Control = regsub(resp.http.Cache-Control, "max-
 age=0", "max-age=300");
     remove resp.http.Expires;
   }
 }

 }}}



 Varnishlog:
 {{{
    10 SessionOpen  c 127.0.0.1 59535 127.0.0.1:8000
    10 ReqStart     c 127.0.0.1 59535 1479748637
    10 RxRequest    c GET
    10 RxURL        c /qt-in-use
    10 RxProtocol   c HTTP/1.1
    10 RxHeader     c Host: 127.0.0.1:8000
    10 RxHeader     c User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X
 10.5; en-GB; rv:1.9.0.8) Gecko/2009032608 Firefox/3.0.8
    10 RxHeader     c Accept:
 text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    10 RxHeader     c Accept-Language: no,an;q=0.8,en-gb;q=0.5,en;q=0.3
    10 RxHeader     c Accept-Encoding: gzip,deflate
    10 RxHeader     c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    10 RxHeader     c Keep-Alive: 300
    10 RxHeader     c Connection: keep-alive
    10 RxHeader     c Referer: http://127.0.0.1:8000/products
    10 RxHeader     c Cookie:
 __utma=96992031.3070035466335688000.1240418157.1240493161.1240506194.4;
 __utmc=96992031;
 __utmz=96992031.1240489309.2.2.utmcsr=localhost:8000|utmccn=(referral)|utmcmd=referral|utmcct=/;
 osas_id=124041815941677170; I18N_LANGUAGE="en"; __utmb=969920
    10 RxHeader     c Pragma: no-cache
    10 RxHeader     c Cache-Control: no-cache
    10 VCL_call     c recv
    10 VCL_return   c lookup
    10 VCL_call     c hash
    10 VCL_return   c hash
    10 VCL_call     c miss
    10 VCL_return   c fetch
    11 BackendOpen  b default 127.0.0.1 59536 127.0.0.1 8080
    10 Backend      c 11 default default
    11 TxRequest    b GET
    11 TxURL        b
 /VirtualHostBase/http/127.0.0.1:8000/www/VirtualHostRoot/qt-in-use
    11 TxProtocol   b HTTP/1.1
    11 TxHeader     b Host: 127.0.0.1:8000
    11 TxHeader     b User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X
 10.5; en-GB; rv:1.9.0.8) Gecko/2009032608 Firefox/3.0.8
    11 TxHeader     b Accept:
 text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    11 TxHeader     b Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    11 TxHeader     b Referer: http://127.0.0.1:8000/products
    11 TxHeader     b Pragma: no-cache
    11 TxHeader     b Accept-Encoding: gzip
    11 TxHeader     b Accept-Language: en
    11 TxHeader     b X-Original-Cookie:
 __utma=96992031.3070035466335688000.1240418157.1240493161.1240506194.4;
 __utmc=96992031;
 __utmz=96992031.1240489309.2.2.utmcsr=localhost:8000|utmccn=(referral)|utmcmd=referral|utmcct=/;
 osas_id=124041815941677170; I18N_LANGUAGE="en"; __
    11 TxHeader     b X-Varnish: 1479748637
    11 TxHeader     b X-Forwarded-For: 127.0.0.1
    11 TxHeader     b Cookie: I18N_LANGUAGE="en"
    11 RxProtocol   b HTTP/1.1
    11 RxStatus     b 200
    11 RxResponse   b OK
    11 RxHeader     b Server: Zope/(Zope 2.10.7-final, python 2.4.6,
 darwin) ZServer/1.1 Plone/3.2.2
    11 RxHeader     b Date: Thu, 23 Apr 2009 17:37:16 GMT
    11 RxHeader     b Content-Length: 7367
    11 RxHeader     b Content-Language: en
    11 RxHeader     b Content-Encoding: gzip
    11 RxHeader     b Expires: Mon, 26 Apr 1999 17:37:16 GMT
    11 RxHeader     b Vary: Accept-Encoding,
    11 RxHeader     b    Accept-Encoding
    11 RxHeader     b Last-Modified: Tue, 10 Mar 2009 13:17:11 GMT
    11 RxHeader     b X-Caching-Rule-Id: plone-content-types
    11 RxHeader     b Cache-Control: max-age=0, s-maxage=86400, must-
 revalidate, proxy-revalidate
    11 RxHeader     b Content-Type: text/html;charset=utf-8
    11 RxHeader     b X-Header-Set-Id: cache-in-proxy-24-hours
    10 ObjProtocol  c HTTP/1.1
    10 ObjStatus    c 200
    10 ObjResponse  c OK
    10 ObjHeader    c Server: Zope/(Zope 2.10.7-final, python 2.4.6,
 darwin) ZServer/1.1 Plone/3.2.2
    10 ObjHeader    c Date: Thu, 23 Apr 2009 17:37:16 GMT
    10 ObjHeader    c Content-Language: en
    10 ObjHeader    c Content-Encoding: gzip
    10 ObjHeader    c Expires: Mon, 26 Apr 1999 17:37:16 GMT
    10 ObjHeader    c Vary: Accept-Encoding,
    10 ObjHeader    c    Accept-Encoding
    10 ObjHeader    c Last-Modified: Tue, 10 Mar 2009 13:17:11 GMT
    10 ObjHeader    c X-Caching-Rule-Id: plone-content-types
    10 ObjHeader    c Cache-Control: max-age=0, s-maxage=86400, must-
 revalidate, proxy-revalidate
    10 ObjHeader    c Content-Type: text/html;charset=utf-8
    10 ObjHeader    c X-Header-Set-Id: cache-in-proxy-24-hours
    11 BackendReuse b default
    10 TTL          c 1479748637 RFC 86400 1240508236 0 0 86400 0
    10 VCL_call     c fetch
    10 VCL_return   c deliver
    10 Length       c 7367
    10 VCL_call     c deliver
    10 VCL_return   c deliver
    10 TxProtocol   c HTTP/1.1
    10 TxStatus     c 200
    10 TxResponse   c OK
    10 TxHeader     c Server: Zope/(Zope 2.10.7-final, python 2.4.6,
 darwin) ZServer/1.1 Plone/3.2.2
    10 TxHeader     c Content-Language: en
    10 TxHeader     c Content-Encoding: gzip
    10 TxHeader     c    Accept-Encoding
    10 TxHeader     c Last-Modified: Tue, 10 Mar 2009 13:17:11 GMT
    10 TxHeader     c X-Caching-Rule-Id: plone-content-types
    10 TxHeader     c Content-Type: text/html;charset=utf-8
    10 TxHeader     c X-Header-Set-Id: cache-in-proxy-24-hours
    10 TxHeader     c Content-Length: 7367
    10 TxHeader     c Vary: Accept-Encoding,Accept-Language
    10 TxHeader     c Date: Thu, 23 Apr 2009 17:37:16 GMT
    10 TxHeader     c X-Varnish: 1479748637
    10 TxHeader     c Via: 1.1 varnish
    10 TxHeader     c Connection: keep-alive
    10 TxHeader     c X-Varnish-Age: 0
    10 TxHeader     c Age: 0
    10 TxHeader     c Cache-Control: max-age=300, s-maxage=0, must-
 revalidate, proxy-revalidate
    10 ReqEnd       c 1479748637 1240508236.245735884 1240508236.643460035
 0.000218868 0.397611141 0.000113010
 }}}

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/494>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list