Raw response
To access raw response, use .read()
method on response. It returns a special object reqsnaked.Bytes
and now it could only be converted to python's bytes()
instance using .as_bytes()
:
Read raw body
client = reqsnaked.Client()
request = reqsnaked.Request(
"GET", "https://httpbin.org/bytes/10", # (1)
)
response = await client.send(request)
data = await response.read()
print(data.as_bytes())
- This endpoint returns 10 random bytes
b'4NI\xff\x11\x0b\x82E\xb3\xa7'
Full code preview
import asyncio
import reqsnaked
async def main():
client = reqsnaked.Client()
request = reqsnaked.Request(
"GET", "https://httpbin.org/bytes/10",
)
response = await client.send(request)
data = await response.read()
print(data.as_bytes())
asyncio.run(main())
Failure
You cannot read from body twice