zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
U
 ý°dLã@s°ddlmZddlZddlZddlmZddlmZddl    m
Z
ddl m Z m Z ddlmZd    gZejejejeejeeffejeejeefffZGd
d    „d    ƒZdS) é)Ú annotationsN)Ú    urlencodeé)Ú
_TYPE_BODY)ÚHTTPHeaderDict)Ú _TYPE_FIELDSÚencode_multipart_formdata)ÚBaseHTTPResponseÚRequestMethodsc
@s¢eZdZdZddddhZd"ddd    œd
d „Zd#d d dddddddœdd„Zd$d d dddddddœdd„Zd%d d ddd ddœdd„Zd&d d ddddd ddœd d!„Z    dS)'r
a·
    Convenience mixin for classes who implement a :meth:`urlopen` method, such
    as :class:`urllib3.HTTPConnectionPool` and
    :class:`urllib3.PoolManager`.
 
    Provides behavior for making common types of HTTP request methods and
    decides which type of request field encoding to use.
 
    Specifically,
 
    :meth:`.request_encode_url` is for sending requests whose fields are
    encoded in the URL (such as GET, HEAD, DELETE).
 
    :meth:`.request_encode_body` is for sending requests whose fields are
    encoded in the *body* of the request using multipart or www-form-urlencoded
    (such as for POST, PUT, PATCH).
 
    :meth:`.request` is for making any kind of request, it will look up the
    appropriate encoding format and use one of the above two methods to make
    the request.
 
    Initializer parameters:
 
    :param headers:
        Headers to include with all requests, unless other headers are given
        explicitly.
    ÚDELETEÚGETÚHEADÚOPTIONSNztyping.Mapping[str, str] | NoneÚNone)ÚheadersÚreturncCs|pi|_dS)N)r)Úselfr©rúOd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\urllib3/_request_methods.pyÚ__init__3szRequestMethods.__init__TÚstrz_TYPE_BODY | NoneÚboolz
str | Nonez
typing.Anyr    )ÚmethodÚurlÚbodyrÚencode_multipartÚmultipart_boundaryÚkwrcKs tdƒ‚dS)NzMClasses extending RequestMethods must implement their own ``urlopen`` method.)ÚNotImplementedError)rrrrrrrrrrrÚurlopen6s
ÿzRequestMethods.urlopenz_TYPE_FIELDS | Noneztyping.Any | None)rrrÚfieldsrÚjsonÚ
urlopen_kwrcKs¾| ¡}|dk    r |dk    r tdƒ‚|dk    rl|dkr:|j ¡}dttj| ¡ƒkrVd|d<tj    |ddd 
d    ¡}|dk    r|||d
<||j kr |j ||f||d œ|—ŽS|j ||f||d œ|—ŽSdS) aá
        Make a request using :meth:`urlopen` with the appropriate encoding of
        ``fields`` based on the ``method`` used.
 
        This is a convenience method that requires the least amount of manual
        effort. It can be used in most situations, while still having the
        option to drop down to more specific methods when necessary, such as
        :meth:`request_encode_url`, :meth:`request_encode_body`,
        or even the lowest level :meth:`urlopen`.
        NzUrequest got values for both 'body' and 'json' parameters which are mutually exclusivez content-typezapplication/jsonú Content-Type)ú,ú:F)Ú
separatorsÚ ensure_asciizutf-8r)r r)ÚupperÚ    TypeErrorrÚcopyÚmaprÚlowerÚkeysÚ_jsonÚdumpsÚencodeÚ_encode_url_methodsÚrequest_encode_urlÚrequest_encode_body)rrrrr rr!r"rrrÚrequestEsDÿ
ÿ
þüûÿÿÿzRequestMethods.requestz_TYPE_ENCODE_URL_FIELDS | None)rrr rr"rcKsD|dkr|j}d|i}| |¡|r4|dt|ƒ7}|j||f|ŽS)z¦
        Make a request using :meth:`urlopen` with the ``fields`` encoded in
        the url. This is useful for request methods like GET, HEAD, DELETE, etc.
        Nrú?)rÚupdaterr)rrrr rr"Úextra_kwrrrr2zs 
z!RequestMethods.request_encode_url)rrr rrrr"rc Ks„|dkr|j}dt|ƒi}|rjd|kr.tdƒ‚|rDt||d\}    }
nt|ƒd}    }
|    |d<|d d|
¡| |¡|j||f|ŽS)a¼
        Make a request using :meth:`urlopen` with the ``fields`` encoded in
        the body. This is useful for request methods like POST, PUT, PATCH, etc.
 
        When ``encode_multipart=True`` (default), then
        :func:`urllib3.encode_multipart_formdata` is used to encode
        the payload with the appropriate content type. Otherwise
        :func:`urllib.parse.urlencode` is used with the
        'application/x-www-form-urlencoded' content type.
 
        Multipart encoding must be used when posting files, and it's reasonably
        safe to use it in other times too. However, it may break request
        signing, such as with OAuth.
 
        Supports an optional ``fields`` parameter of key/value strings AND
        key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
        the MIME type is optional. For example::
 
            fields = {
                'foo': 'bar',
                'fakefile': ('foofile.txt', 'contents of foofile'),
                'realfile': ('barfile.txt', open('realfile').read()),
                'typedfile': ('bazfile.bin', open('bazfile').read(),
                              'image/jpeg'),
                'nonamefile': 'contents of nonamefile field',
            }
 
        When uploading a file, providing a filename (the first parameter of the
        tuple) is optional but recommended to best mimic behavior of browsers.
 
        Note that if ``headers`` are supplied, the 'Content-Type' header will
        be overwritten because it depends on the dynamic random boundary string
        which is used to compose the body of the request. The random boundary
        string can be explicitly set with the ``multipart_boundary`` parameter.
        NrrzFrequest got values for both 'fields' and 'body', can only specify one.)Úboundaryz!application/x-www-form-urlencodedr#)rrr)rrÚ
setdefaultr6r) rrrr rrrr"r7rÚ content_typerrrr3‘s(- ÿÿ þ
z"RequestMethods.request_encode_body)N)NNTN)NNNN)NN)NNTN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r1rrr4r2r3rrrrr
s* ùù9ûù)Ú
__future__rr!r.ÚtypingÚ urllib.parserZ_base_connectionrÚ _collectionsrÚfilepostrrÚresponser    Ú__all__ÚUnionÚSequenceÚTuplerÚbytesÚMappingZ_TYPE_ENCODE_URL_FIELDSr
rrrrÚ<module>s     ÿÿ