Skip to content

fix: inject the live reload script across response chunks - #296

Open
jihtsan wants to merge 1 commit into
lepture:masterfrom
jihtsan:codex/242-inject-later-chunks
Open

jihtsan wants to merge 1 commit into
lepture:masterfrom
jihtsan:codex/242-inject-later-chunks

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 18, 2026

Copy link
Copy Markdown

Fixes #242.

HTML responses with a closing </head> beyond the first response chunk currently receive no reload script. Keep searching later chunks, retaining at most six trailing bytes so a case-insensitive closing tag split across chunks is recognized. Stop after the first injection; preserve the existing complete-first-chunk path and non-HTML behavior.

For a streaming HTML response whose closing tag is not yet known, remove Content-Length before headers are sent and let Tornado select framing. This avoids the Content-Length overflow described in the Issue without buffering the entire page. If no closing tag appears, all original bytes are emitted.

Validation:

  • New regression cases fail on the unchanged implementation, including a real loopback HTTP response with a >64KiB head.
  • Python 3.13.12 / Tornado 6.5.10: python -m pytest -q passes 17 tests and 8 subtests.
  • Python 3.9.6 / Tornado 6.2: python -m unittest discover -v passes 17 tests.
  • Independent verification passes 500 deterministic chunk partitions with bounded pending bytes, and real StaticFileHandler requests for long HTML, no closing head, HEAD, and Range/206.
  • git diff --check passes.

Not run locally: Python 3.7/3.8, Linux, Windows, or the Makefile's legacy nosetests command. The repository currently has a tag publishing workflow but no PR test workflow; these results are local validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Injection of livereload.js fails when head section is too long

1 participant