mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
disable h2c upgrades
This commit is contained in:
parent
e769b1fa9a
commit
39a8d4dc22
@ -12,6 +12,7 @@ from mitmproxy.addons import stickyauth
|
||||
from mitmproxy.addons import stickycookie
|
||||
from mitmproxy.addons import streambodies
|
||||
from mitmproxy.addons import upstream_auth
|
||||
from mitmproxy.addons import disable_h2c_upgrade
|
||||
|
||||
|
||||
def default_addons():
|
||||
@ -30,4 +31,5 @@ def default_addons():
|
||||
serverplayback.ServerPlayback(),
|
||||
clientplayback.ClientPlayback(),
|
||||
upstream_auth.UpstreamAuth(),
|
||||
disable_h2c_upgrade.DisableH2CleartextUpgrade(),
|
||||
]
|
||||
|
21
mitmproxy/addons/disable_h2c_upgrade.py
Normal file
21
mitmproxy/addons/disable_h2c_upgrade.py
Normal file
@ -0,0 +1,21 @@
|
||||
class DisableH2CleartextUpgrade:
|
||||
|
||||
"""
|
||||
We currently only support HTTP/2 over a TLS connection. Some clients try
|
||||
to upgrade a connection from HTTP/1.1 to h2c, so we need to remove those
|
||||
headers to avoid protocol errors if one endpoints suddenly starts sending
|
||||
HTTP/2 frames.
|
||||
"""
|
||||
|
||||
def process_flow(self, f):
|
||||
if f.request.headers.get('upgrade', '') == 'h2c':
|
||||
del f.request.headers['upgrade']
|
||||
if 'connection' in f.request.headers:
|
||||
del f.request.headers['connection']
|
||||
if 'http2-settings' in f.request.headers:
|
||||
del f.request.headers['http2-settings']
|
||||
|
||||
# Handlers
|
||||
|
||||
def request(self, f):
|
||||
self.process_flow(f)
|
Loading…
Reference in New Issue
Block a user