Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting response.expires via timedelta produces an incorrect header value #430

Open
mschmitzer opened this issue Apr 23, 2021 · 0 comments

Comments

@mschmitzer
Copy link

When using a timedelta to calculate the absolute timestamp, webob uses datetime.now(), which is in local time. This is later re-interpreted to be UTC, which yields an "Expires" header value that is off by the UTC offset of the local timezone.

Example in CEST:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, timedelta
>>> from webob import Response
>>> datetime.utcnow()
datetime.datetime(2021, 4, 23, 13, 48, 1, 541647)
>>> r = Response()
>>> r.expires = timedelta(seconds=0)
>>> r.expires
datetime.datetime(2021, 4, 23, 15, 48, 13, tzinfo=UTC)

The example shows that setting expires to a zero timedelta produces a header value two hours in the future.

The cache_expires method does the right when passed a timedelta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant