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

Replace hard-coded cookie expiration dates in WPT Python files #28829

Merged
merged 1 commit into from May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions content-security-policy/reporting/support/set-cookie.py
@@ -1,3 +1,5 @@
from datetime import date

def main(request, response):
"""
Returns cookie name and path from query params in a Set-Cookie header.
Expand All @@ -11,15 +13,16 @@ def main(request, response):
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Set-Cookie: match-slash=1; Path=/; Expires=Wed, 09 Jun 2021 10:18:14 GMT
< Set-Cookie: match-slash=1; Path=/; Expires=09 Jun 2021 10:18:14 GMT
< Server: BaseHTTP/0.3 Python/2.7.12
< Date: Tue, 04 Oct 2016 18:16:06 GMT
< Content-Length: 80
"""

name = request.GET[b'name']
path = request.GET[b'path']
cookie = b"%s=1; Path=%s; Expires=Wed, 09 Jun 2021 10:18:14 GMT" % (name, path)
expiry_year = date.today().year + 1
cookie = b"%s=1; Path=%s; Expires=09 Jun %d 10:18:14 GMT" % (name, path, expiry_year)

headers = [
(b"Content-Type", b"application/json"),
Expand Down
7 changes: 5 additions & 2 deletions cookies/resources/set-cookie.py
@@ -1,3 +1,5 @@
from datetime import date

def main(request, response):
"""
Returns cookie name and path from query params in a Set-Cookie header.
Expand All @@ -11,15 +13,16 @@ def main(request, response):
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Set-Cookie: match-slash=1; Path=/; Expires=Wed, 09 Jun 2021 10:18:14 GMT
< Set-Cookie: match-slash=1; Path=/; Expires=09 Jun 2021 10:18:14 GMT
< Server: BaseHTTP/0.3 Python/2.7.12
< Date: Tue, 04 Oct 2016 18:16:06 GMT
< Content-Length: 80
"""

name = request.GET[b'name']
path = request.GET[b'path']
cookie = b"%s=1; Path=%s; Expires=Wed, 09 Jun 2021 10:18:14 GMT" % (name, path)
expiry_year = date.today().year + 1
cookie = b"%s=1; Path=%s; Expires=09 Jun %d 10:18:14 GMT" % (name, path, expiry_year)

headers = [
(b"Content-Type", b"application/json"),
Expand Down