filter-pypi-responses: stream package requests that hit the proxy

mitmproxy was buffering all requests (except pythonhosted.*), causing
pip to time out when getting big packages from custom URLs.

Setting flow.response.stream in the responseheaders hook fixes this.
This commit is contained in:
Yorick van Pelt 2023-10-18 11:46:13 +02:00
parent 1f57898e4f
commit 318a87ff55
No known key found for this signature in database
GPG Key ID: D8D3CC6D951384DE

View File

@ -85,6 +85,11 @@ Response format:
"""
def responseheaders(flow: http.HTTPFlow) -> None:
if "/simple/" not in flow.request.url:
flow.response.stream = True
def response(flow: http.HTTPFlow) -> None:
if not "/simple/" in flow.request.url:
return