From 2002971d670b27dd3591b8d4dc46eb0953382e62 Mon Sep 17 00:00:00 2001 From: ropoctl Date: Sat, 27 Dec 2025 23:44:27 -0800 Subject: [PATCH 1/2] Fix problems with callers confused by gzip encoding When caller allows gzip encoding, and the backend sends content-encoding gzip, we either need to recompress, or pop the header for the caller. --- proxy.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/proxy.py b/proxy.py index 7bcf3fb..e0eb44b 100644 --- a/proxy.py +++ b/proxy.py @@ -4,6 +4,7 @@ # dependencies = [ # "aiohttp", # "arize-phoenix-otel", +# "multidict", # "opentelemetry-api", # "opentelemetry-sdk", # "pyyaml", @@ -12,17 +13,18 @@ import json import logging -import yaml from typing import Dict, Any, List + from aiohttp import web import aiohttp - +import multidict from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.resources import Resource from openinference.semconv.trace import SpanAttributes +import yaml # Configure logging logging.basicConfig(level=logging.INFO) @@ -285,10 +287,14 @@ async def handle_generate_content(request): response_json.get("usageMetadata", {}).get("totalTokenCount", 0), ) + mutable_headers = CIMultiDict(upstream_response.headers) + mutable_headers.pop('Transfer-Encoding', None) + mutable_headers.pop('Content-Encoding', None) + return web.Response( status=upstream_response.status, body=response_body, - headers=dict(upstream_response.headers), + headers=mutable_headers, ) except Exception as e: From 1e37e12810950a79cacb16671d5cb5cd842bde19 Mon Sep 17 00:00:00 2001 From: ropoctl Date: Sun, 28 Dec 2025 14:05:56 -0800 Subject: [PATCH 2/2] Update proxy.py --- proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy.py b/proxy.py index e0eb44b..8cee1f4 100644 --- a/proxy.py +++ b/proxy.py @@ -17,7 +17,7 @@ from aiohttp import web import aiohttp -import multidict +from multidict import CIMultiDict from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor