aio-libs / aio-libs/aiohttp

Access peername info for closed ClientResponse transport?

Aberta
#4,645 2 comentários 2 reações 0 responsáveis Ver no GitHub
enhancement
Linguagem predominante
Python
Estrelas
16.5k
Forks
2.4k
Merge médio
17h 22min
PRs com merge (30d)
212

Descrição

🐣 **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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.