Skip to content

Commit

Permalink
Merge pull request #278 from Lucas-C/issue-277
Browse files Browse the repository at this point in the history
Not injecting live script when serving non-HTML content - fix #277
  • Loading branch information
lepture authored Nov 7, 2024
2 parents 96fb2e1 + 1103f94 commit 7703672
Showing 1 changed file with 2 additions and 1 deletion.
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

0 comments on commit 7703672

Please sign in to comment.