fix check for streaming response

This commit is contained in:
Ishaan Jaff 2024-11-20 15:15:21 -08:00
parent 9f916636e1
commit acf350a2fb

View file

@ -478,10 +478,9 @@ async def pass_through_request( # noqa: PLR0915
json=_parsed_body,
)
if (
response.headers.get("content-type") is not None
and response.headers["content-type"] == "text/event-stream"
):
verbose_proxy_logger.debug("response.headers= %s", response.headers)
if _is_streaming_response(response) is True:
try:
response.raise_for_status()
except httpx.HTTPStatusError as e:
@ -621,6 +620,13 @@ def create_pass_through_route(
return endpoint_func
def _is_streaming_response(response: httpx.Response) -> bool:
_content_type = response.headers.get("content-type")
if _content_type is not None and "text/event-stream" in _content_type:
return True
return False
async def initialize_pass_through_endpoints(pass_through_endpoints: list):
verbose_proxy_logger.debug("initializing pass through endpoints")