Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d431c75297 |
@@ -22,12 +22,6 @@ async def patched_html_response(request, filepath: str, status_code: int, **data
|
|||||||
Returns:
|
Returns:
|
||||||
Patched Response object, or original response if not 200.
|
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)
|
resp = await vitedev.handle(request, frontend, filepath)
|
||||||
# Pass through non-200 responses
|
# Pass through non-200 responses
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
|
|||||||
@@ -63,4 +63,13 @@ async def handle(request, frontend, filepath: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Fallback to frontend.handle for cache negotiation
|
# 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)
|
return frontend.handle(request, filepath)
|
||||||
|
|||||||
Reference in New Issue
Block a user