/ lib / urllib3 / request.pyc
request.pyc
 1  o

 2  ��Yca�@s>ddlmZddlmZddlmZdgZGdd�de�ZdS)�)�absolute_import�)�encode_multipart_formdata)�	urlencode�RequestMethodsc@sZeZdZdZhd�Zddd�Z				ddd�Zdd	d
 3  �Zddd�Z				dd
d�Z	dS)ra�
 4      Convenience mixin for classes who implement a :meth:`urlopen` method, such
 5      as :class:`urllib3.HTTPConnectionPool` and
 6      :class:`urllib3.PoolManager`.
 7  
 8      Provides behavior for making common types of HTTP request methods and
 9      decides which type of request field encoding to use.
10  
11      Specifically,
12  
13      :meth:`.request_encode_url` is for sending requests whose fields are
14      encoded in the URL (such as GET, HEAD, DELETE).
15  
16      :meth:`.request_encode_body` is for sending requests whose fields are
17      encoded in the *body* of the request using multipart or www-form-urlencoded
18      (such as for POST, PUT, PATCH).
19  
20      :meth:`.request` is for making any kind of request, it will look up the
21      appropriate encoding format and use one of the above two methods to make
22      the request.
23  
24      Initializer parameters:
25  
26      :param headers:
27          Headers to include with all requests, unless other headers are given
28          explicitly.
29      >�OPTIONS�GET�DELETE�HEADNcCs|pi|_dS�N)�headers)�selfr�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\request.py�__init__(szRequestMethods.__init__TcKstd��)NzMClasses extending RequestMethods must implement their own ``urlopen`` method.)�NotImplementedError)r
�method�url�bodyr�encode_multipart�multipart_boundary�kwrrr�urlopen+s
30  �zRequestMethods.urlopencKsN|��}||d<||jvr|j||f||d�|��S|j||f||d�|��S)a�
31          Make a request using :meth:`urlopen` with the appropriate encoding of
32          ``fields`` based on the ``method`` used.
33  
34          This is a convenience method that requires the least amount of manual
35          effort. It can be used in most situations, while still having the
36          option to drop down to more specific methods when necessary, such as
37          :meth:`request_encode_url`, :meth:`request_encode_body`,
38          or even the lowest level :meth:`urlopen`.
39          �request_url)�fieldsr)�upper�_encode_url_methods�request_encode_url�request_encode_body)r
rrrr�
40  urlopen_kwrrr�request:s"
41  ������zRequestMethods.requestcKsH|dur|j}d|i}|�|�|r|dt|�7}|j||fi|��S)z�
42          Make a request using :meth:`urlopen` with the ``fields`` encoded in
43          the url. This is useful for request methods like GET, HEAD, DELETE, etc.
44          Nr�?)r�updaterr)r
rrrrr�extra_kwrrrrRs
45  z!RequestMethods.request_encode_urlcKs�|dur|j}dii}|r1d|vrtd��|r t||d�\}	}
46  nt|�d}	}
47  |	|d<d|
48  i|d<|d�|�|�|�|j||fi|��S)a�
49          Make a request using :meth:`urlopen` with the ``fields`` encoded in
50          the body. This is useful for request methods like POST, PUT, PATCH, etc.
51  
52          When ``encode_multipart=True`` (default), then
53          :func:`urllib3.encode_multipart_formdata` is used to encode
54          the payload with the appropriate content type. Otherwise
55          :func:`urllib.parse.urlencode` is used with the
56          'application/x-www-form-urlencoded' content type.
57  
58          Multipart encoding must be used when posting files, and it's reasonably
59          safe to use it in other times too. However, it may break request
60          signing, such as with OAuth.
61  
62          Supports an optional ``fields`` parameter of key/value strings AND
63          key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
64          the MIME type is optional. For example::
65  
66              fields = {
67                  'foo': 'bar',
68                  'fakefile': ('foofile.txt', 'contents of foofile'),
69                  'realfile': ('barfile.txt', open('realfile').read()),
70                  'typedfile': ('bazfile.bin', open('bazfile').read(),
71                                'image/jpeg'),
72                  'nonamefile': 'contents of nonamefile field',
73              }
74  
75          When uploading a file, providing a filename (the first parameter of the
76          tuple) is optional but recommended to best mimic behavior of browsers.
77  
78          Note that if ``headers`` are supplied, the 'Content-Type' header will
79          be overwritten because it depends on the dynamic random boundary string
80          which is used to compose the body of the request. The random boundary
81          string can be explicitly set with the ``multipart_boundary`` parameter.
82          NrrzFrequest got values for both 'fields' and 'body', can only specify one.)�boundaryz!application/x-www-form-urlencodedzContent-Type)r�	TypeErrorrrr"r)r
rrrrrrrr#r�content_typerrrrbs(-���
83  z"RequestMethods.request_encode_bodyr)NNTN)NN)
84  �__name__�
85  __module__�__qualname__�__doc__rrrr rrrrrrr	s 
86  
8788  
89  �N)	�
90  __future__r�filepostr�packages.six.moves.urllib.parser�__all__�objectrrrrr�<module>s
91