Skip to content

Connection close on Response #156

Open
@Kludex

Description

@Kludex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions