-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Hi,
I use httpx AsyncClient to send a get request ,I always get the response with null content, I change to use aiohttp ,it works ok ,get the right content.Here is my code:
EVIROMENT: python3.11.5 httpx 0.25.1
async def httpxGetUrl(url):
async with httpx.AsyncClient() as client:
resp = await client.get(url)
content = await resp.aread()
print(content)
# content = resp.text
# print(content)
async def aiohttpGetUrl(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
token = await resp.text()
print(token.encode('utf-8').decode('unicode_escape'))
return token
if __name__ == '__main__':
import asyncio
asyncio.run(httpxGetUrl('http://127.0.0.1:5000/Pay?Id=655cede5-5a3b-401d-00cf-9753508162e4'))
# asyncio.run(aiohttpGetUrl('http://127.0.0.1:5000/Pay?Id=655cede5-5a3b-401d-00cf-9753508162e4'))
But If I use a proxy to send the get request it will receive the right response:
async def httpxGetUrl(url):
async with httpx.AsyncClient(
verify=False,
proxies=proxies,
) as client:
resp = await client.get(url)
content = await resp.aread()
print(content)
# content = resp.text
# print(content)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels