From 318a87ff5550b6b4de35705e00f0b0f7940dd072 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Wed, 18 Oct 2023 11:46:13 +0200 Subject: [PATCH] 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. --- pkgs/fetchPipMetadata/filter-pypi-responses.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/fetchPipMetadata/filter-pypi-responses.py b/pkgs/fetchPipMetadata/filter-pypi-responses.py index eea126be..4c188568 100644 --- a/pkgs/fetchPipMetadata/filter-pypi-responses.py +++ b/pkgs/fetchPipMetadata/filter-pypi-responses.py @@ -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