cachecontrol icon indicating copy to clipboard operation
cachecontrol copied to clipboard

CacheControl fails on invalid (non-integer) max-age header

Open hakanw opened this issue 10 years ago • 5 comments

CacheControl totally fails on this URL:

'http://www.meristation.com/v3/podcasts_rss.php'

Due to the max-age header being '600s' which is obviously wrong, but I think CacheControl should catch the ValueError (trying to cast the string to an int) and handle it gracefully.

Exception:

ValueError
invalid literal for int() with base 10: '600s'
Location: cachecontrol/controller.py, cache_response:241

hakanw avatar Jul 29 '15 13:07 hakanw

I agree. That said, CacheControl probably should raise an error of its own to let you know that there were cache headers present, but they were invalid. You might otherwise expect that this was cached if you inspected the response and missed that header being malformed.

sigmavirus24 avatar Jul 29 '15 13:07 sigmavirus24

Maybe a warning or log an error? But to die completely I think is over the top. I use cachecontrol as a wrapper around all my HTTP handling, so I expect it to be solid and withstand all the weird stuff on the web. ;)

hakanw avatar Jul 29 '15 14:07 hakanw

Yeah, I guess its unreasonable for anyone talking to the internet to handle any failures at all

sigmavirus24 avatar Jul 29 '15 14:07 sigmavirus24

Haha, I meant the opposite of course. But yes, handling the internet is a pretty big task. :)

hakanw avatar Jul 29 '15 14:07 hakanw

@hakanw Thanks for catching this one! I'll take a look.

ionrock avatar Jul 29 '15 14:07 ionrock

Long fixed, I believe.

woodruffw avatar Jul 03 '24 21:07 woodruffw