René's URL Explorer Experiment


Title: A 304 with content-length is accepted or rejected by framing alone · Issue #1330 · python-hyper/h2 · GitHub

Open Graph Title: A 304 with content-length is accepted or rejected by framing alone · Issue #1330 · python-hyper/h2

X Title: A 304 with content-length is accepted or rejected by framing alone · Issue #1330 · python-hyper/h2

Description: While working on #1328 I found two more holes in the same function, and they turn out to be two halves of one problem. I have not touched anything — the measurements are in a standalone probe, and I would rather agree on the direction fi...

Open Graph Description: While working on #1328 I found two more holes in the same function, and they turn out to be two halves of one problem. I have not touched anything — the measurements are in a standalone probe, and ...

X Description: While working on #1328 I found two more holes in the same function, and they turn out to be two halves of one problem. I have not touched anything — the measurements are in a standalone probe, and ...

Opengraph URL: https://github.com/python-hyper/h2/issues/1330

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A 304 with content-length is accepted or rejected by framing alone","articleBody":"While working on #1328 I found two more holes in the same function, and they turn out to be two halves of one problem. I have not touched anything — the measurements are in a standalone probe, and I would rather agree on the direction first.\n\n## A 304 or 204 carrying `content-length` is accepted or rejected depending on framing\n\n`_initialize_content_length` (`src/h2/stream.py:1369`) implements exactly one exemption, `self.request_method == b\"HEAD\"` (`:1375`). RFC 9113 § 8.1.1 names three messages that are \"defined as having no content\": 204, 304, and the response to HEAD, and it says a message defined to have no content \"MAY have a non-zero content-length header field\". RFC 9110 § 8.6 repeats it for 304 — that is how a client learns the size of the cached entity. `H2Stream` never stores `:status`, so the other two cannot be written as the code stands. Observable today, on `master` and on #1329 alike:\n\n```\n304 + content-length: 1234 + empty DATA with END_STREAM   -> InvalidBodyLengthError: Expected 1234 bytes, received 0\n304 + content-length: 1234 + END_STREAM on the HEADERS    -> accepted ['ResponseReceived', 'StreamEnded']\n204 + content-length: 1234 + empty DATA with END_STREAM   -> InvalidBodyLengthError: Expected 1234 bytes, received 0\n```\n\nOne message, two verdicts, decided purely by which frame carried END_STREAM. That is an enforcement that rejects something the RFC permits, and it is reachable from a plain `H2Connection.receive_data` on a legitimate response.\n\n## The same hole #1328 fixed, in the other branch of the same `if`\n\n`receive_headers` (`:1113`) — the `else` branch, i.e. a HEADERS block that is not trailers, calls `_initialize_content_length(headers)` and nothing else. So a bodyless message that ends on the HEADERS is never policed at all:\n\n```\nPOST content-length: 15 + END_STREAM on the HEADERS, no DATA  -> accepted ['RequestReceived', 'StreamEnded']\n200  content-length: 1234 + END_STREAM on the HEADERS         -> accepted ['ResponseReceived', 'StreamEnded']\n```\n\n`content-length: 15` with nothing sent is the same lie #1328 is about, and `_actual_content_length` stays 0.\n\nThe obvious one-line fix is not safe on its own. Adding `if end_stream: self._track_content_length(0, end_stream=True)` to that branch, measured:\n\n```\n                                    before        after that line\nPOST content-length: 15, no body    accepted      InvalidBodyLengthError(15, 0)   \u003c- intended\n304  content-length: 1234, no body  accepted      InvalidBodyLengthError(1234, 0) \u003c- new breakage\n204  content-length: 1234, no body  accepted      InvalidBodyLengthError(1234, 0) \u003c- new breakage\nPOST content-length: 0, no body     accepted      accepted                          \u003c- control\nGET  no content-length, no body     accepted      accepted                          \u003c- control\n```\n\nSo the 204/304 exemption has to land first, or with it. That is why I am asking rather than sending a patch: the exemption is a design call. Setting `self._expected_content_length = 0` for 204/304 mirrors the HEAD precedent and additionally makes DATA after a 204 an error, which RFC 9110 § 6.3 implies; setting it to `None` only skips the comparison. I lean to `0`, but that is your call, and `H2Stream` would need to start recording `:status`.\n\n\u003cdetails>\u003csummary>Two smaller ones in the same file, and what I am not reporting\u003c/summary>\n\n## Two smaller ones in the same file, both one-line\n\n- `send_headers` (`:909`) assigns `self.request_method = extract_method_header(bytes_headers)` on *every* header block, including a trailers block, which has no `:method` — so outbound trailers overwrite a remembered `b\"HEAD\"` with `None`. `H2Connection.send_headers(1, HEAD)` then a trailers block, then a `200` + `content-length: 1234` + empty DATA + END_STREAM, raises where it should not. Guarding on `method is not None` fixes it.\n- `remotely_pushed` (`:1052`) records `self._authority` but never the method, so a pushed stream never gets the HEAD exemption at all. A `PUSH_PROMISE` with `:method: HEAD` followed by `200` + `content-length: 1234` + empty DATA + END_STREAM raises; the identical push with `:method: GET` raises the same way, which is the tell that the method is simply not consulted.\n\n## Not reported\n\n- **RST_STREAM or a local reset mid-body** runs no length check, and should not: the message is abandoned and the stream is closed, so nothing later can contradict the sender. Measured, no error, and I read that as specified rather than a bug.\n- **A `content-length` in *outbound* trailers** is a real asymmetry — h2 will send a trailers block carrying `content-length: 0`, and feeding those exact bytes back into an h2 client raises `ProtocolError: Received content-length header in trailer`. But fixing it means changing the trailer field in four existing tests in `tests/test_basic_logic.py`, so I would file that separately rather than widen this.\n- **A 1xx carrying `content-length`** is accepted and then overwritten. Inconsistent with the new trailers rule, but the RFC puts that obligation on the sender and no wrong byte is ever compared, so I do not think it is worth an interop risk.\n\n\u003c/details>\n\n## Verification\n\n`uv run --frozen pytest tests/ -q` is 1670 passed at 100.00% coverage (466 statements, 98 branches in `stream.py`, 0 missed), on `d2b43d0`. Every scenario above is a runtime measurement against the real `H2Connection`, not a reading. I have the probe as a standalone script and the 17 assertions as a pytest file; say the word and I will open a PR with the exemption and the HEADERS-frame check together, at 100% coverage.\n","author":{"url":"https://github.com/feiiiiii5","@type":"Person","name":"feiiiiii5"},"datePublished":"2026-09-27T10:16:22Z","url":"https://github.com/python-hyper/h2/issues/1330"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7d18e459-724e-9415-36a6-05a285816ff7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA4E2:3AC956:361C605:487D9F5:6B06EF96
html-safe-nonce785693ec8728d60613ded7049cb9a70833ed4bdd82a812f3af1ff3fd1579d8a8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEUyOjNBQzk1NjozNjFDNjA1OjQ4N0Q5RjU6NkIwNkVGOTYiLCJ2aXNpdG9yX2lkIjoiMjI4NzA5NDUwODA5OTY2MTcxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacac35dc08c465ac1df0f7389737df13c1ca2d29a3c61367b23172ea9006fb347f
hovercard-subject-tagissue:5601832896
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-hyper/h2/1330/issue_layout
twitter:imagehttps://opengraph.githubassets.com/513daa60069ee3af383adcd98f4d0f926a852551e80a5e2bf8c683b8ffc54d98/python-hyper/h2/issues/1330
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/513daa60069ee3af383adcd98f4d0f926a852551e80a5e2bf8c683b8ffc54d98/python-hyper/h2/issues/1330
og:image:altWhile working on #1328 I found two more holes in the same function, and they turn out to be two halves of one problem. I have not touched anything — the measurements are in a standalone probe, and ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefeiiiiii5
hostnamegithub.com
expected-hostnamegithub.com
None351ea5ca38a5758919d44ee52c70fe9003c0c2dfa20f04effd7fac0c5330c16b
turbo-cache-controlno-preview
go-importgithub.com/python-hyper/h2 git https://github.com/python-hyper/h2.git
octolytics-dimension-user_id13035907
octolytics-dimension-user_loginpython-hyper
octolytics-dimension-repository_id37996233
octolytics-dimension-repository_nwopython-hyper/h2
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id37996233
octolytics-dimension-repository_network_root_nwopython-hyper/h2
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release891bde3f438884e9c6c7ccd826f33805910a978b
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python-hyper/h2/issues/1330#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fh2%2Fissues%2F1330
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fh2%2Fissues%2F1330
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-hyper%2Fh2
Reloadhttps://github.com/python-hyper/h2/issues/1330
Reloadhttps://github.com/python-hyper/h2/issues/1330
Reloadhttps://github.com/python-hyper/h2/issues/1330
python-hyperhttps://github.com/python-hyper
h2https://github.com/python-hyper/h2
Codehttps://github.com/python-hyper/h2
Issues21 (21)https://github.com/python-hyper/h2/issues
Pull requests23 (23)https://github.com/python-hyper/h2/pulls
Actionshttps://github.com/python-hyper/h2/actions
Projectshttps://github.com/python-hyper/h2/projects
Wikihttps://github.com/python-hyper/h2/wiki
Security and quality2 (2)https://github.com/python-hyper/h2/security
Insightshttps://github.com/python-hyper/h2/insights
https://github.com/python-hyper/h2
New issuehttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1330
New issuehttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1330
#1344https://github.com/python-hyper/h2/pull/1344
A 304 with content-length is accepted or rejected by framing alonehttps://github.com/python-hyper/h2/issues/1330#top
#1344https://github.com/python-hyper/h2/pull/1344
https://github.com/feiiiiii5
feiiiiii5https://github.com/feiiiiii5
on Sep 27, 2026https://github.com/python-hyper/h2/issues/1330#issue-5601832896
#1328https://github.com/python-hyper/h2/issues/1328
#1329https://github.com/python-hyper/h2/pull/1329
#1328https://github.com/python-hyper/h2/issues/1328
#1328https://github.com/python-hyper/h2/issues/1328
Sign up for freehttps://github.com/signup?return_to=https://github.com/python-hyper/h2/issues/1330
Sign in to commenthttps://github.com/login?return_to=https://github.com/python-hyper/h2/issues/1330
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.