Skip to content

Add "network_stream" extension to HTTP/2. #724

@lovelydinosaur

Description

@lovelydinosaur

Currently the "network_stream" response extension is only exposed on HTTP/1.1 connections...

>>> import httpcore
>>> with httpcore.ConnectionPool() as http:
...     r = http.request("GET", "https://www.example.com")
...     print(r.extensions["network_stream"].get_extra_info("server_addr"))
... 
('93.184.216.34', 443)

...and is not exposed on HTTP/2 connections...

>>> import httpcore
>>> with httpcore.ConnectionPool(http2=True) as http:
...     r = http.request("GET", "https://www.example.com")
...     print(r.extensions["network_stream"].get_extra_info("server_addr"))
... 

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
KeyError: 'network_stream'

We should resolve this.

Relevant sections of the code are here...

extensions={
"http_version": b"HTTP/2",
"stream_id": stream_id,
},

extensions={
"http_version": b"HTTP/2",
"stream_id": stream_id,
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions