Access peername info for closed ClientResponse transport?
- 主要语言
- Python
- 星标
- 16.5k
- 派生
- 2.4k
- 平均合并
- 17 小时 22 分钟
- 30 天内合并 PR
- 212
描述
🐣 **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.
贡献指南
评估
这个 Issue 还没有评估数据。