Skip to content

Commit

Permalink
fix: use response content
Browse files Browse the repository at this point in the history
  • Loading branch information
NarekA committed Dec 4, 2023
1 parent 80972b1 commit d287848
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions jina/serve/runtimes/gateway/request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,22 @@ async def _load_balance(self, request):
try:
async with aiohttp.ClientSession() as session:

request_kwargs = {}
request_kwargs = {
'headers': request.headers,
'params': request.query,
}
try:
payload = await request.json()
payload = await request.content.read()
if payload:
request_kwargs['json'] = payload
request_kwargs['data'] = payload
except Exception:
self.logger.debug('No JSON payload found in request')

Check warning on line 171 in jina/serve/runtimes/gateway/request_handling.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/gateway/request_handling.py#L170-L171

Added lines #L170 - L171 were not covered by tests

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'):
if response.content_type.endswith('stream'):

# Create a StreamResponse with the same headers and status as the target response
stream_response = web.StreamResponse(
Expand Down

0 comments on commit d287848

Please sign in to comment.