aio-libs / aio-libs/aiohttp

Access peername info for closed ClientResponse transport?

オープン
#4,645 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
16.5k
フォーク
2.4k
平均マージ
17時間 22分
マージ済み PR(30日)
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。