packages.urllib3.util.request

Module Contents

Functions

make_headers(keep_alive=None,accept_encoding=None,user_agent=None,basic_auth=None,proxy_basic_auth=None,disable_cache=None) Shortcuts for generating request headers.
make_headers(keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=None, proxy_basic_auth=None, disable_cache=None)

Shortcuts for generating request headers.

Parameters:
  • keep_alive – If True, adds ‘connection: keep-alive’ header.
  • accept_encoding – Can be a boolean, list, or string. True translates to ‘gzip,deflate’. List will get joined by comma. String will be used as provided.
  • user_agent – String representing the user-agent you want, such as “python-urllib3/0.6”
  • basic_auth – Colon-separated username:password string for ‘authorization: basic …’ auth header.
  • proxy_basic_auth – Colon-separated username:password string for ‘proxy-authorization: basic …’ auth header.
  • disable_cache – If True, adds ‘cache-control: no-cache’ header.

Example:

>>> make_headers(keep_alive=True, user_agent="Batman/1.0")
{'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
>>> make_headers(accept_encoding=True)
{'accept-encoding': 'gzip,deflate'}