diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 1583e9fcb..b92b3f503 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -181,5 +181,11 @@ class Options(optmanager.OptManager): TLS key size for certificates and CA. """ ) + self.add_option( + "relax_http_form_validation", bool, False, + """ + Disable HTTP form validation. + """ + ) self.update(**kwargs) diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py index efe5740e3..7b3806f12 100644 --- a/mitmproxy/proxy/protocol/http.py +++ b/mitmproxy/proxy/protocol/http.py @@ -281,10 +281,12 @@ class HttpLayer(base.Layer): self.send_error_response(400, msg) return False - validate_request_form(self.mode, request) + if not self.config.options.relax_http_form_validation: + validate_request_form(self.mode, request) self.channel.ask("requestheaders", f) # Re-validate request form in case the user has changed something. - validate_request_form(self.mode, request) + if not self.config.options.relax_http_form_validation: + validate_request_form(self.mode, request) if request.headers.get("expect", "").lower() == "100-continue": # TODO: We may have to use send_response_headers for HTTP2