0

I am trying to print out the method and headers of a request I am sending. I can do it for the response of the request, but not the actual request itself.

Here's where the problem lies:

async with session.get('url', params=params) as resp:
    print(resp.method)
    content = await
    resp.read()
Michael S.
  • 3,050
  • 4
  • 19
  • 34
d dd
  • 1
  • If I understand correctly, it could be a duplicate of [that](https://stackoverflow.com/questions/20658572/python-requests-print-entire-http-request-raw) – Talon Aug 12 '22 at 08:30
  • @Talon that is for the requests library, not aiohttp. – d dd Aug 12 '22 at 08:42

1 Answers1

0

Is request_info what you are looking for ? See the documentation for extra details.


 async with session.get('https://www.python.org/', params=params) as resp:
    print(resp.request_info)
    content = await resp.read()

> RequestInfo(url=URL('https://www.python.org/'), method='GET', headers=<CIMultiDictProxy('Host': 'www.python.org', 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Python/3.9 aiohttp/3.8.1')>, real_url=URL('https://www.python.org/'))
edg
  • 930
  • 6
  • 17