Let's say I have an addon that modifies a response from specific endpoints, like the one provided in the documentation example: https://docs.mitmproxy.org/stable/api/events.html#event-hooks
Within that response
function I want to make an http(s) request to an unrelated endpoint. To make http(s) requests I use the requests library. Problem is, if I specify nothing but the url in the requests get/post method, I get ValueError: check_hostname requires server_hostname
error. After researching this I got the impression that the underlying urllib3
library requires extra proxy information. But if I try to provide proxies object that looks like:
proxies={
'http': f'http://127.0.0.1:{port}',
'https': f'https://127.0.0.1:{port}',
}
I get the following error instead: requests.exceptions.ProxyError: HTTPSConnectionPool(host='<hostname>', port=443): Max retries exceeded with url: <endpoint> (Caused by ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1114: The handshake operation timed out')))
I assume that any request made inside addon scripts goes through mitmproxy itself, where it successfully dies. Hence, I was wondering how to properly make http requests within mitmproxy addons?
OS: Windows 10
Mitmproxy version: 6.0.2