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

Access peername info for closed ClientResponse transport? #4645

Open
deed02392 opened this issue Mar 18, 2020 · 1 comment
Open

Access peername info for closed ClientResponse transport? #4645

deed02392 opened this issue Mar 18, 2020 · 1 comment

Comments

@deed02392
Copy link

🐣 Is your feature request related to a problem? Please describe.
When a request has followed a redirect, I have to use the history data on the ClientResponse object to access the various HTTP requests that lead me to the current page data. If a hostname was used to produce the ClientResponse info for historic objects, there is no API to determine what IP address was used to obtain that data/redirect response.

If the connection is still alive, one can use the transport to get_extra_info and hence the peername has the IP and port tuple. However, with redirects this is not possible because the connection transport information is gone already.

💡 Describe the solution you'd like
Some static information recorded on the ClientResponse object that contains the remote peername info that was used to connect and retrieve the data.

Describe alternatives you've considered
It is not even possible to use tracing to record the IP after the socket has been acquired because the closest appropriate trace signal does not provide any connection data (such as the peername) in its params: https://docs.aiohttp.org/en/stable/tracing_reference.html#traceconnectioncreateendparams

My current solution is to extract the URL from the ClientResponse object and resolve it. However, when the hostname resolves to multiple IP addresses, it is not currently possible to determine what IP aiohttp actually used to fetch the response!

📋 Additional context
I am using aiohttp to perform mass default HTTP page fetching.

@webknjaz
Copy link
Member

Try sending a PR if you have a solution in mind.

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

No branches or pull requests

2 participants