Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asyncio binary response is being decoded forcefully #279

Open
KDanisme opened this issue Oct 21, 2022 · 0 comments
Open

Asyncio binary response is being decoded forcefully #279

KDanisme opened this issue Oct 21, 2022 · 0 comments

Comments

@KDanisme
Copy link

Describe the bug
When using the asyncio client session and getting a binary response, uplink crashes due to trying to decode it.

To Reproduce
Define a method that has a response that contains a binary value

@get("/some-binary-file")
def get_binary(self): pass

call await get_binary()

Expected behavior
get an aiohttp.ClientResponse that contains a bytes object

Actual behavior

Traceback (most recent call last):
  File "uplink/clients/io/asyncio_strategy.py", line 32, in execute
    return await executable.execute()
  File "uplink/clients/io/asyncio_strategy.py", line 21, in invoke
    response = await callback.on_success(response)
  File "uplink/clients/io/asyncio_strategy.py", line 19, in invoke
    response = await callback.on_failure(type(error), error, tb)
  File "uplink/clients/io/execution.py", line 108, in on_failure
    return self._io.fail(exc_type, exc_val, exc_tb)
  File "uplink/clients/io/interfaces.py", line 300, in fail
    compat.reraise(exc_type, exc_val, exc_tb)
  File "six.py", line 719, in reraise
    raise value
  File "uplink/clients/io/asyncio_strategy.py", line 16, in invoke
    response = await func(*args, **kwargs)
  File "uplink/clients/aiohttp_.py", line 25, in new_callback
    await response.text()
  File "aiohttp/client_reqrep.py", line 1085, in text
    return self._body.decode(  # type: ignore[no-any-return,union-attr]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xac in position 10: invalid start byte

Additional context
I realise there's a await response.text in File "uplink/clients/aiohttp_.py", line 25, in new_callback which i presume awaits the response inorder to wrap it or something, i simply replaced it with response.read() which gets the response without trying to decode it, and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants