Skip to content

How to get Remote Address with httpx? #1569

Answered by SK-415
baiyyee asked this question in Q&A
Discussion options

You must be logged in to vote

Message to future people looking for this feature.

It's now support with httpx>=0.21.0 or technically httpcore>=0.14.0. See request extensions.

import httpx

with httpx.Client() as client:
    r = client.get("https://example.com")
    print(r.extensions["network_stream"].get_extra_info("server_addr"))
    print(r.extensions["network_stream"].get_extra_info("client_addr"))

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants