OLD | NEW |
1 # urllib3/request.py | 1 # urllib3/request.py |
2 # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) | 2 # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) |
3 # | 3 # |
4 # This module is part of urllib3 and is released under | 4 # This module is part of urllib3 and is released under |
5 # the MIT License: http://www.opensource.org/licenses/mit-license.php | 5 # the MIT License: http://www.opensource.org/licenses/mit-license.php |
6 | 6 |
7 try: | 7 try: |
8 from urllib.parse import urlencode | 8 from urllib.parse import urlencode |
9 except ImportError: | 9 except ImportError: |
10 from urllib import urlencode | 10 from urllib import urlencode |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 Provides behavior for making common types of HTTP request methods and | 24 Provides behavior for making common types of HTTP request methods and |
25 decides which type of request field encoding to use. | 25 decides which type of request field encoding to use. |
26 | 26 |
27 Specifically, | 27 Specifically, |
28 | 28 |
29 :meth:`.request_encode_url` is for sending requests whose fields are encoded | 29 :meth:`.request_encode_url` is for sending requests whose fields are encoded |
30 in the URL (such as GET, HEAD, DELETE). | 30 in the URL (such as GET, HEAD, DELETE). |
31 | 31 |
32 :meth:`.request_encode_body` is for sending requests whose fields are | 32 :meth:`.request_encode_body` is for sending requests whose fields are |
33 encoded in the *body* of the request using multipart or www-orm-urlencoded | 33 encoded in the *body* of the request using multipart or www-form-urlencoded |
34 (such as for POST, PUT, PATCH). | 34 (such as for POST, PUT, PATCH). |
35 | 35 |
36 :meth:`.request` is for making any kind of request, it will look up the | 36 :meth:`.request` is for making any kind of request, it will look up the |
37 appropriate encoding format and use one of the above two methods to make | 37 appropriate encoding format and use one of the above two methods to make |
38 the request. | 38 the request. |
39 | 39 |
40 Initializer parameters: | 40 Initializer parameters: |
41 | 41 |
42 :param headers: | 42 :param headers: |
43 Headers to include with all requests, unless other headers are given | 43 Headers to include with all requests, unless other headers are given |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 'application/x-www-form-urlencoded') | 133 'application/x-www-form-urlencoded') |
134 | 134 |
135 if headers is None: | 135 if headers is None: |
136 headers = self.headers | 136 headers = self.headers |
137 | 137 |
138 headers_ = {'Content-Type': content_type} | 138 headers_ = {'Content-Type': content_type} |
139 headers_.update(headers) | 139 headers_.update(headers) |
140 | 140 |
141 return self.urlopen(method, url, body=body, headers=headers_, | 141 return self.urlopen(method, url, body=body, headers=headers_, |
142 **urlopen_kw) | 142 **urlopen_kw) |
OLD | NEW |