Skip to content

Commit 09528c6

Browse files
rustyconoverclaude
andcommitted
Support custom X-VGI encoding headers for zstd compression and bump version to 0.1.25
Add X-VGI-Accept-Encoding and X-VGI-Content-Encoding custom headers to bypass proxies/CDNs that strip standard Content-Encoding headers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2714b93 commit 09528c6

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vgi-rpc"
3-
version = "0.1.24"
3+
version = "0.1.25"
44
description = "Vector Gateway Interface - RPC framework based on Apache Arrow"
55
readme = "README.md"
66
requires-python = ">=3.13"

vgi_rpc/http/_server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,11 @@ def __init__(self, level: int) -> None:
18101810

18111811
def process_request(self, req: falcon.Request, resp: falcon.Response) -> None:
18121812
"""Decompress zstd request bodies; record client Accept-Encoding."""
1813-
# Check if the client accepts zstd responses
1813+
# Check if the client accepts zstd responses (standard or custom header)
18141814
accept_encoding = req.get_header("Accept-Encoding") or ""
1815-
req.context.client_accepts_zstd = "zstd" in accept_encoding
1815+
custom_accept = req.get_header("X-VGI-Accept-Encoding") or ""
1816+
req.context.client_accepts_zstd = "zstd" in accept_encoding or "zstd" in custom_accept
1817+
req.context.use_custom_encoding_header = "zstd" in custom_accept
18161818

18171819
# Decompress request body if Content-Encoding: zstd
18181820
content_encoding = req.get_header("Content-Encoding") or ""
@@ -1852,7 +1854,10 @@ def process_response(
18521854
compressed = _compress_body(body, self._level)
18531855
resp.data = compressed
18541856
resp.stream = None
1855-
resp.set_header("Content-Encoding", "zstd")
1857+
if getattr(req.context, "use_custom_encoding_header", False):
1858+
resp.set_header("X-VGI-Content-Encoding", "zstd")
1859+
else:
1860+
resp.set_header("Content-Encoding", "zstd")
18561861

18571862

18581863
class _CapabilitiesMiddleware:

0 commit comments

Comments
 (0)