Compare commits

..
1 Commits
2 changed files with 9 additions and 6 deletions
-6
View File
@@ -22,12 +22,6 @@ async def patched_html_response(request, filepath: str, status_code: int, **data
Returns:
Patched Response object, or original response if not 200.
"""
# Strip caching/compression headers to get raw uncompressed content
cache_headers = {b"if-none-match", b"if-modified-since", b"accept-encoding"}
request.scope["headers"] = [
(k, v) for k, v in request.scope["headers"] if k.lower() not in cache_headers
]
resp = await vitedev.handle(request, frontend, filepath)
# Pass through non-200 responses
if resp.status_code != 200:
+9
View File
@@ -63,4 +63,13 @@ async def handle(request, frontend, filepath: str):
)
# Fallback to frontend.handle for cache negotiation
# Strip accept-encoding to get uncompressed content (needed for HTML patching)
strip_headers = {b"accept-encoding", b"if-none-match", b"if-modified-since"}
request.scope["headers"] = [
(k, v) for k, v in request.scope["headers"] if k.lower() not in strip_headers
]
# Invalidate cached Headers object (it doesn't re-read scope after first access)
if hasattr(request, "_headers"):
del request._headers
return frontend.handle(request, filepath)