What are passed to *args and **kwargs in hooks of requests

Viewed 56

Assume now I have a simple python script like

import requests
def do_something(response, *args, **kwargs):
    #do something
url = "https://example.com/get/"
resp = requests.get(url, hooks={'response':do_something})

My question is: what exactly are passed to *args and **kwargs when getting the response?

I didn't find the answer on official documentation, so if you'd like to help me I'd be appreciate.

1 Answers

Thanks guys, after reading the source code myself, I find the answer:

args will not be passed values.

kwargs is a dict containing information about following items:

  1. time_out
  2. proxies
  3. stream
  4. verify
  5. cert

The answer could be found in request.py, line 582-587 and session.py line 671-708, at requests version 2.27.1.

Related