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

Some cookies are missing on HTTP/2 #287

Closed
dekkers opened this issue May 8, 2024 · 1 comment · Fixed by #296
Closed

Some cookies are missing on HTTP/2 #287

dekkers opened this issue May 8, 2024 · 1 comment · Fixed by #296
Labels
bug Something isn't working wsgi Issue related to WSGI protocol
Milestone

Comments

@dekkers
Copy link
Contributor

dekkers commented May 8, 2024

When running Granian with HTTP/2 some cookies are missing. I created the following test application:

def app(environ, start_response):
    headers = [
        ('Content-Type', 'text/html'),
        ('Set-Cookie', 'csrftoken=abcdef; expires=Mon, 05 May 2025 22:45:47 GMT; HttpOnly; Max-Age=31449600; Path=/; SameSite=Strict; Secure'),
        ('Set-Cookie', 'sessionid=123456; expires=Mon, 05 May 2025 22:45:47 GMT; HttpOnly; Max-Age=31449600; Path=/; SameSite=Strict; Secure'),
    ]
    try:
        cookies = environ["HTTP_COOKIE"]
    except KeyError:
        cookies = ""

    start_response('200 OK', headers)
    return [f'<html><body>Cookies: {cookies}</body></html>'.encode()]

If I run Granian with HTTP/2 and visis the site with Firefox or Chrome I only see the sessionid cookie, not the csrftoken cookie. With curl it seems to work however. I ran Granian using:

granian --http 2 --ssl-keyfile key.pem --ssl-certificate cert.pem --interface wsgi app:app

If I run it with HTTP/1 it works without problem however:

granian --http 1 --ssl-keyfile key.pem --ssl-certificate cert.pem --interface wsgi app:app

It might be caused by hyperium/hyper#2528. I don't know if the Firefox and Chrome split the cookies and curl does not, but if that is the case it would explain why there is no problem with curl but there is a problem with Firefox and Chrome.

@gi0baro
Copy link
Member

gi0baro commented May 11, 2024

@dekkers no, this is a Granian bug on WSGI protocol, thank you for reporting this

@gi0baro gi0baro added bug Something isn't working wsgi Issue related to WSGI protocol labels May 11, 2024
@gi0baro gi0baro added this to the 1.3 milestone May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wsgi Issue related to WSGI protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants