Skip to content

How to force enable HTTP/2.0 #3261

Closed
Closed
@ArkadyRudenko

Description

@ArkadyRudenko

I have an HTTP/2.0 server and I want to ping/test it using an httpx client.
I use this docs: https://www.python-httpx.org/http2/

And the client send this request

GET /hello HTTP/1.1\r\nHost: localhost:8080\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUser-Agent: python-httpx/0.27.0\r\n\r\n

The server needs a HTTP2-Settings header to send a upgrade response ("RFC: A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one "HTTP2-Settings" header field")

See RFC: https://datatracker.ietf.org/doc/html/rfc7540#section-3.2 and https://datatracker.ietf.org/doc/html/rfc7540#section-3.2.1

If the server responds with 101 Switching Protocols the client is not ready for this.
Question: How can my server upgrade httpx client to HTTP/2.0?

My client:

import httpx
import asyncio


async def main():
    async with httpx.AsyncClient(http2=True) as client:
        r = await client.get("http://localhost:8080/hello")
        print(r.http_version)


asyncio.run(main())

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