Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not injecting live script when serving non-HTML content - fix #277 #278

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion livereload/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def __init__(self, request):
super().__init__(request)

def transform_first_chunk(self, status_code, headers, chunk, finishing):
if HEAD_END in chunk:
is_html = "html" in headers.get("Content-Type", "")
if is_html and HEAD_END in chunk:
chunk = chunk.replace(HEAD_END, self.script + HEAD_END, 1)
if 'Content-Length' in headers:
length = int(headers['Content-Length']) + len(self.script)
Expand Down