Skip to content
Myr

header expanding

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 1d0a5b2 · Browse files · 1 file+30 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+30 added−0 removed

  • other:+30 added−0 removed

1 file+30 added−0 removed

modified:requests/utils.py+30 added
13 unmodified lines
14import re15import zlib161718def header_expand(header_dict):19 """Returns an HTTP Header value string from a dictionary.2021 Example expansion::2223 # Accept: text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c24 {'text/x-dvi': {'q': '.8', 'mxb': '100000', 'mxt': '5.0'}, 'text/x-c': {}}25 """2627 collector = []2829 for i, (value, params) in enumerate(header_dict.items()):30 _params = []3132 for p_k, p_v in params.items():3334 _params.append('{k}={v}'.format(k=p_k, v=p_v))3536 if len(params):37 collector.append(value)38 collector.append('; ')39 collector.append('; '.join(_params))4041 if not len(header_dict) == i+1:42 collector.append(', ')4344 return ''.join(collector)45464748def dict_from_cookiejar(cj):49 """Returns a key/value dictionary from a CookieJar.5051 :param cj: CookieJar object to extract cookies from.
147 unmodified lines