On 3/30/06, Thomas Broyer <t.b...@gm...> wrote:
> I think this could be solved in many ways:
> - either line 606, by initializing "info" to a "Status: 504" message,
> but we must then make sure this message doesn't have an "etag", or
> other things that could break "cache freshness" computation
> - or line 647, looking for an empty "info" (or an "info" lacking a
> "status", or catching the KeyError, or =96better=96 looking for an empty
> cacheFullPath) and then returning a "Status: 504" message
> - or line 721, using int(self.get('status', 504)) instead of
> int(self['status']) --or catching the KeyError exception and then
> defaulting to a "Status: 504" message.
>
> I'd rather go for the second choice, replacing lines 646 to 649 with
> something like:
> if entry_disposition =3D=3D "FRESH":
> if not os.path.exists(cacheFullPath):
> # This should be the case only for a
> "Cache-Control: only-if-cached" request
> return CACHED_VERSION_UNAVAILABLE
> else:
> response =3D Response(info)
> response.fromcache =3D True
> return (response, content)
>
> after having defined a global variable:
> CACHED_VERSION_UNAVAILABLE =3D (
> Response(rfc822.Message(StringIO.StringIO("""\
> Status: 504
> Content-Type: text/plain
> """)),
> "You asked for a cached version only, and no cached version is availa=
ble."
> )
Yes, I prefer this last option, and that's the form
of the fix I put in place.
Thanks,
-joe
--
Joe Gregorio http://bitworking.org
|