Skip to content

Commit

Permalink
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 e0a8118
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 = {

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

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/gateway/request_handling.py#L162

Added line #L162 was not covered by tests
'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#L166-L171

Added lines #L166 - L171 were not covered by tests

async with _RequestContextManager(

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

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/gateway/request_handling.py#L173

Added line #L173 was not covered by tests
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'):

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

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/gateway/request_handling.py#L177

Added line #L177 was not covered by tests

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

0 comments on commit e0a8118

Please sign in to comment.