diff options
| author | ubdussamad <samadhaque23@gmail.com> | 2021-05-17 18:46:55 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-17 08:16:55 -0500 |
| commit | 066ed766de83accb990b86a2b714feec0a32697d (patch) | |
| tree | 72de10ab8a8774b5c4ed307a93dfdb852273ce59 /docs/user-guide.rst | |
| parent | 52079f1df9d1e3810e02762458bc665c1a438778 (diff) | |
| download | urllib3-066ed766de83accb990b86a2b714feec0a32697d.tar.gz | |
Added HTTPHeaderDict to top level module
Diffstat (limited to 'docs/user-guide.rst')
| -rw-r--r-- | docs/user-guide.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/user-guide.rst b/docs/user-guide.rst index 53464d6a..5fb9bc7f 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -147,6 +147,23 @@ You can specify headers as a dictionary in the ``headers`` argument in :meth:`~p >>> json.loads(r.data.decode('utf-8'))['headers'] {'X-Something': 'value', ...} +Or you can use the ``HTTPHeaderDict`` class to create multi-valued HTTP headers: + +.. code-block:: pycon + + >>> from urllib3 import HTTPHeaderDict + >>> headers = HTTPHeaderDict() + >>> headers.add('Accept', 'application/json') + >>> headers.add('Accept', 'text/plain') + >>> r = http.request( + ... 'GET', + ... 'http://httpbin.org/headers', + ... headers=headers + ... ) + >>> json.loads(r.data.decode('utf-8'))['headers'] + {'Accept': 'application/json, text/plain', ...} + + Query Parameters ~~~~~~~~~~~~~~~~ |
