mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
Added addon to suppress the sending of 502 Bad Gateway response… (#4299)
* WIP: Added option to suppress the sending of 502 Bad Gateway responses if the server is not responding * Revert "WIP: Added option to suppress the sending of 502 Bad Gateway responses if the server is not responding" This reverts commit 21b74f38b7ddeb63c5070cb4ca4928d3c37d12fe. * Added addon which suppresses the bad gateway error messages sent by mitmproxy * fix type annotation Co-authored-by: Maximilian Hils <github@maximilianhils.com>
This commit is contained in:
parent
5b6d75614e
commit
97bf522165
16
examples/contrib/suppress_error_responses.py
Normal file
16
examples/contrib/suppress_error_responses.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
This script suppresses the 502 Bad Gateway messages, mitmproxy sends if the server is not responsing correctly.
|
||||||
|
For example, this functionality can be helpful if mitmproxy is used in between a web scanner and a web application.
|
||||||
|
Without this script, if the web application under test crashes, mitmproxy will send 502 Bad Gateway responses.
|
||||||
|
These responses are irritating the web application scanner since they obfuscate the actual problem.
|
||||||
|
"""
|
||||||
|
from mitmproxy import http
|
||||||
|
from mitmproxy.exceptions import HttpSyntaxException
|
||||||
|
|
||||||
|
|
||||||
|
def error(self, flow: http.HTTPFlow):
|
||||||
|
"""Kills the flow if it has an error different to HTTPSyntaxException.
|
||||||
|
Sometimes, web scanners generate malformed HTTP syntax on purpose and we do not want to kill these requests.
|
||||||
|
"""
|
||||||
|
if flow.error is not None and not isinstance(flow.error, HttpSyntaxException):
|
||||||
|
flow.kill()
|
Loading…
Reference in New Issue
Block a user