Skip to content

Commit

Permalink
docs: Add comment for content type
Browse files Browse the repository at this point in the history
  • Loading branch information
NarekA committed Dec 4, 2023
1 parent 7932b0d commit 80972b1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions jina/serve/runtimes/gateway/request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ async def _load_balance(self, request):
async with _RequestContextManager(
session._request(request.method, target_url, **request_kwargs)
) as response:
# Looking for application/octet-stream, text/event-stream, text/stream
if request.content_type.endswith('stream'):

# Create a StreamResponse with the same headers and status as the target response
Expand All @@ -188,13 +189,12 @@ async def _load_balance(self, request):
# Close the stream response once all chunks are sent
await stream_response.write_eof()
return stream_response
else:
content = await response.read()
return web.Response(
body=content,
status=response.status,
content_type=response.content_type,
)
content = await response.read()
return web.Response(
body=content,
status=response.status,
content_type=response.content_type,
)
except aiohttp.ClientError as e:
return web.Response(text=f'Error: {str(e)}', status=500)

Expand Down

0 comments on commit 80972b1

Please sign in to comment.