You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export https_proxy="http://127.0.0.1:8080"
curl https://nodomain123.com/part1/part2/part3 # fails
curl https://google.com/part1/part2/part3 # works
The text was updated successfully, but these errors were encountered:
balazser
changed the title
Request mock with response fails if host cannot be resolved.
Mocked request with response fails if host cannot be resolved.
Nov 5, 2020
@balazser Just as an update, I am able to reproduce this, and indeed it is a strange behaviour by mitmproxy that it acts as though an error response was received, but the request handler is not called. If you enable debug logging with --set console_eventlog_verbosity=debug --set termlog_verbosity=debug arguments to mitmproxy or mitmdump, you can see that the Moxy Response: log is output for the non-existent domain, but the Request: log is not.
My initial thought was to simply work around this by providing a "response" handler for the same path, but here the response doesn't even have a path associated with it, and trying to respond to the empty path crashes mitmproxy:
So this seems unfixable from the script side (at least without deeper knowledge of what would be a valid way to override the error). I suggest posting an issue for mitmproxy itself. You can reproduce this with a simple script that just has something like:
Subject of the issue
The mocked request fails if the target host does not exist.
According to the doc
A request handler is triggered when the client makes a request. This occurs before anything is sent to the server
In practice it seems the host gets somehow resolved
Expected behaviour
In case of a match the request returns with value regardless the host.
Actual behaviour
Error message
Steps to reproduce
Use the following config.
mitmproxy -s moxy.py --set mock=config/example.json
The text was updated successfully, but these errors were encountered: