From 1103f942bd681cca85b7432ce7ed93797cc861e5 Mon Sep 17 00:00:00 2001 From: Lucas Cimon <925560+Lucas-C@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:24:54 +0200 Subject: [PATCH] Not injecting live script when serving non-HTML content - fix #277 --- livereload/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/livereload/server.py b/livereload/server.py index e6d8d8e..a05faf8 100644 --- a/livereload/server.py +++ b/livereload/server.py @@ -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)