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

Response.age mishandled as datetime instead of int (or timedelta) #408

Closed
cvrebert opened this issue Jul 14, 2013 · 2 comments
Closed

Response.age mishandled as datetime instead of int (or timedelta) #408

cvrebert opened this issue Jul 14, 2013 · 2 comments
Assignees
Milestone

Comments

@cvrebert
Copy link
Contributor

Environment:

Flask==0.10.1
Werkzeug==0.9.1

Test case:

#/usr/bin/env python2.7
from flask import Flask, Response

app = Flask(__name__)

@app.route('/')
def root():
    resp = Response()
    resp.age = 42
    return resp

if __name__ == "__main__":
    client = app.test_client()
    resp = client.get('/')
    print "age property:", resp.age
    print "Age header:", resp.headers['Age']

Result:

age property: 1970-01-01 00:00:42
Age header: Thu, 01 Jan 1970 00:00:42 GMT

Expected 42 instead in both cases (though personally I'd optimally prefer timedelta(seconds=42) in the former case).
The HTTP spec says (in part; emphasis added):

The Age response-header field conveys the sender's estimate of the amount of time since the response (or its revalidation) was generated at the origin server.
age-value = delta-seconds
Age values are non-negative decimal integers, representing time in seconds.

@untitaker
Copy link
Contributor

Just a heads up, @cvrebert: This can't be fixed in any minor version, so this'll probably get fixed in 1.0 .

@untitaker
Copy link
Contributor

Will be fixed in 1.0.

@davidism davidism modified the milestones: 0.13, 1.0 Apr 12, 2017
davidism added a commit that referenced this issue Apr 13, 2017
Continue #414: Fix #408: Response.age is semantically a timedelta, not a datetime
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants