diff --git a/backend/open_webui/routers/ollama.py b/backend/open_webui/routers/ollama.py index 23a43aaaa9..b283db9ae8 100644 --- a/backend/open_webui/routers/ollama.py +++ b/backend/open_webui/routers/ollama.py @@ -55,14 +55,15 @@ log = logging.getLogger(__name__) # response body. Forwarding them verbatim causes desktop / programmatic # clients to attempt decompression of an already-decoded payload, resulting # in ZlibError. See https://github.com/aio-libs/aiohttp/issues/4462. -_STRIP_PROXY_HEADERS = frozenset({'Content-Encoding', 'Content-Length', 'Transfer-Encoding'}) +# Also drop server and date: uvicorn adds its own and forwarding both duplicates them. +_STRIP_PROXY_HEADERS = frozenset({'content-encoding', 'content-length', 'transfer-encoding', 'server', 'date'}) _MODEL_LIST_TIMEOUT = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST) BASE_MODELS_CACHE_KEY = f'{REDIS_KEY_PREFIX}:models:base' def _clean_proxy_headers(raw_headers) -> dict: - """Return a copy of *raw_headers* with stale encoding headers removed.""" - return {k: v for k, v in raw_headers.items() if k not in _STRIP_PROXY_HEADERS} + """Return a copy of *raw_headers* without the encoding, server and date headers.""" + return {k: v for k, v in raw_headers.items() if k.lower() not in _STRIP_PROXY_HEADERS} async def send_get_request( diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index c62b2f7194..8c8f96183e 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -74,15 +74,16 @@ log = logging.getLogger(__name__) # response body. Forwarding them verbatim causes desktop / programmatic # clients to attempt decompression of an already-decoded payload, resulting # in ZlibError. See https://github.com/aio-libs/aiohttp/issues/4462. -_STRIP_PROXY_HEADERS = frozenset({'Content-Encoding', 'Content-Length', 'Transfer-Encoding'}) +# Also drop server and date: uvicorn adds its own and forwarding both duplicates them. +_STRIP_PROXY_HEADERS = frozenset({'content-encoding', 'content-length', 'transfer-encoding', 'server', 'date'}) _MODEL_LIST_TIMEOUT = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST) _UNSUPPORTED_OPENAI_MODEL_KEYWORDS = ('babbage', 'dall-e', 'davinci', 'embedding', 'tts', 'whisper') BASE_MODELS_CACHE_KEY = f'{REDIS_KEY_PREFIX}:models:base' def _clean_proxy_headers(raw_headers) -> dict: - """Return a copy of *raw_headers* with stale encoding headers removed.""" - return {k: v for k, v in raw_headers.items() if k not in _STRIP_PROXY_HEADERS} + """Return a copy of *raw_headers* without the encoding, server and date headers.""" + return {k: v for k, v in raw_headers.items() if k.lower() not in _STRIP_PROXY_HEADERS} async def send_get_request(