-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replacement of entire file #65
Replacement of entire file #65
Comments
This is definitely possible but not from the command line. You'll have to write a script that hooks into the request or response callback functions. For example, say you wanted to replace the entire response for every response going to the proxy client. You could write a response call back such as: def response(context, fl):
flread = flow.FlowReader(open('/tmp/response.flow', 'r'))
flstream = flread.stream()
flreplace = flstream.next()
fl.response._load_state(flreplace.response._get_state()) This will replace the entire state of the response with pre-recorded flow for every response. If you want to just override the content you can replace fl.response.content with some predetermed content. The only caveat is that the pre-recorded flow must be in the tnetstring format used by mitmproxy. You can either record the flow with mitmproxy or if you have a pcap file you can use mitmextract to extract and convert the flow. Hope this helps. |
cjneasbi's solution is the right way for now. Down the track, we may add some utility feature to make this easier, but I'm closing this issue for now. |
Hello, congrats for mitmproxy :)
It's possibile to completely replace a response body with a local file? I tried this way but I failed:
--replace=:site.css:.*:~/site.css
thanks
The text was updated successfully, but these errors were encountered: