Replies: 3 comments 5 replies
-
How are you launching mitmproxy? Are you 100% sure that the request does not go through mitmproxy (transparent mode?)? Because it sounds exactly like that. It wouldn't produce an infinite loop, but your sync request would just lock up the entire proxy until it times out and the request hook finishes to give control back to the proxy core. Can you provide a minimal repro? The exact command you use to start mitmproxy and a complete script. You can probably just make a request to example.com for demo purposes. |
Beta Was this translation helpful? Give feedback.
-
You typically want to use an |
Beta Was this translation helpful? Give feedback.
-
thanks for the repository |
Beta Was this translation helpful? Give feedback.
-
I tried to create an http request inside the mitmproxy but does not seem to work. Here is the gist of what I am doing:
import requests
...
def request(self, flow: http.HTTPFlow) -> None:
response = requests.post(url, headers={"X-Api-Key": API_KEY},
json=event, timeout=timeout, proxies={})
The call times out. I see some related questions but they were trying to creating http.HTTPRequest object itself.
https://stackoverflow.com/questions/60957418/how-to-make-a-request-inside-a-simple-mitmproxy-script
I don't need to do that. I just need to make a simple http call.
If I make this async (fire-and-forget), then it works, but if I need to wait for the call to return then it never works.
My initial problem was not specifying an empty proxies parameter to prevent the call to go through mitmproxy again and thereby creating an infinite loop. But after adding the empty proxies, the call still doesn't return in sync mode.
Beta Was this translation helpful? Give feedback.
All reactions