Check flow.killable before killing prior knowledge h2 connections. (#7514)

* check for killable flow

* [autofix.ci] apply automated fixes

* add test

* changelog

* restructure test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Sujal Singh 2025-01-27 19:29:27 +05:30 committed by GitHub
parent ca8df49519
commit c5402a490a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View file

@ -17,6 +17,8 @@
([#7497](https://github.com/mitmproxy/mitmproxy/pull/7497), @sujaldev)
- Add mitmweb tutorial to docs.
([#7509](https://github.com/mitmproxy/mitmproxy/pull/7509), @EstherRoeth)
- Fixed a bug that caused mitmproxy to crash when loading prior knowledge h2 flows.
([#7514](https://github.com/mitmproxy/mitmproxy/pull/7514), @sujaldev)
## 12 January 2025: mitmproxy 11.1.0

View file

@ -30,7 +30,8 @@ class DisableH2C:
and f.request.http_version == "HTTP/2.0"
)
if is_connection_preface:
f.kill()
if f.killable:
f.kill()
logging.warning(
"Initiating HTTP/2 connections with prior knowledge are currently not supported."
)

View file

@ -37,3 +37,18 @@ class TestDisableH2CleartextUpgrade:
a.request(f)
assert not f.killable
assert f.error.msg == flow.Error.KILLED_MESSAGE
def test_non_killable_flows(self):
with taddons.context() as tctx:
a = disable_h2c.DisableH2C()
tctx.configure(a)
f = tflow.tflow()
f.request = tutils.treq(
method=b"PRI",
path=b"*",
http_version=b"HTTP/2.0",
)
f.kill()
a.request(f)