jech / polipo

The Polipo caching HTTP proxy
http://www.pps.jussieu.fr/~jch/software/polipo/
MIT License
1.8k stars 354 forks source link

Warning headers are probably incorrect #18

Open jech opened 10 years ago

jech commented 10 years ago

The code for generating HTTP Warning headers is dodgy, and probably provides incorrect data in some cases.

vfaronov commented 8 years ago

For example, Polipo generates 110 - "Response is Stale" when the origin server’s response contains an Expires in the past (which is often done to prevent caching):

$ curl --proxy http://localhost:8123 -siG httpbin.org/response-headers \
>     --data-urlencode 'Expires=Sat, 30 Jan 2016 11:55:00 GMT'
HTTP/1.1 200 OK
Content-Length: 116
Date: Sat, 30 Jan 2016 11:55:46 GMT
Expires: Sat, 30 Jan 2016 11:55:00 GMT
Via: 1.1 polipo
Server: nginx
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Connection: keep-alive
Warning: 110 polipo:8123 Object is stale

{
  "Content-Length": "116", 
  "Content-Type": "application/json", 
  "Expires": "Sat, 30 Jan 2016 11:55:00 GMT"
}

As a general rule:

1xx warn-codes describe the freshness or validation status of the response, and so they MUST be deleted by a cache after validation. They can only be generated by a cache when validating a cached entry, and MUST NOT be generated in any other situation.