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

Connection close on Response #156

Open
Kludex opened this issue Nov 25, 2022 · 3 comments
Open

Connection close on Response #156

Kludex opened this issue Nov 25, 2022 · 3 comments

Comments

@Kludex
Copy link
Contributor

Kludex commented Nov 25, 2022

Hi there 👋

I was trying to improve the test coverage on Uvicorn, and I noticed something interesting...

The server can't send connection: close headers on Response. If you set it, h11 will convert it to Connection: close (capitalized version).

This code:

            print(headers)
            event = h11.Response(
                status_code=status_code, headers=headers, reason=reason
            )
            print(event)
            output = self.conn.send(event)
            print(output)

Outputs the following:

[[b'content-type', b'text/plain; charset=utf-8'], [b'content-length', b'12'], (b'connection', b'close')]
Response(status_code=200, headers=<Headers([(b'content-type', b'text/plain; charset=utf-8'), (b'content-length', b'12'), (b'connection', b'close')])>, http_version=b'1.1', reason=b'OK')
b'HTTP/1.1 200 OK\r\ncontent-type: text/plain; charset=utf-8\r\ncontent-length: 12\r\nConnection: close\r\n\r\n'

So... I'm here looking for instructions, more than "asking to change". Is it fine to be like this? I want this info, so I can write proper tests on uvicorn, as the other HTTP implementation uses httptools, and I can send connection: close there.

@njsmith
Copy link
Member

njsmith commented Nov 25, 2022 via email

@Kludex
Copy link
Contributor Author

Kludex commented Nov 25, 2022

So... Should I create a PR to change this behavior, or is it fine?

Really not a big deal for me... I just noticed it when working on this: encode/uvicorn#1776

@njsmith
Copy link
Member

njsmith commented Nov 25, 2022 via email

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