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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
U
Þ=®daã@s$ddlmZddlZddlZddlZddlmZddlm    Z    ddl
m Z ddl
m Z ddl
m Z dd    l
mZdd
l
mZdd l
mZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZej rddl!m"Z"ddl!m#Z#Gdd„deƒZdS)é)Ú annotationsN)ÚBytesIOé)Ú_wsgi_decoding_dance)ÚCombinedMultiDict)ÚEnvironHeaders)Ú FileStorage)ÚImmutableMultiDict)Úiter_multi_items)Ú    MultiDict)Ú
BadRequest)ÚUnsupportedMediaType©Údefault_stream_factory)ÚFormDataParser)ÚRequest)Úcached_property)Úenviron_property)Ú _get_server)Úget_input_stream)ÚWSGIApplication)ÚWSGIEnvironmentcs¶eZdZUdZdZded<dZded<dZeZ    ded<d    ed
<d ed <dfd    d d ddœ‡fdd„ Z
e ddddœdd„ƒZ e dddœdd„ƒZ dgddddddœdd „Zed d!œd"d#„ƒZd$d!œd%d&„Zdd!œd'd(„Zdd!œd)d*„Zdd!œd+d,„Zdd!œd-d.„Zdd!œd/d0„Zedd!œd1d2„ƒZeejed3d4d5Zed6d!œd7d8„ƒZejdhd d9d d6d:œd;d<„ƒZ ejdid d>d d?d:œd@d<„ƒZ djd d d dAd:œdBd<„Z edCd!œdDdE„ƒZ!edFd!œdGdH„ƒZ"edId!œdJdK„ƒZ#ed?d!œdLdM„ƒZ$ed?d!œdNdO„ƒZ%ee&dPdQd5Z'ee(dRdSd5Z)ee(dTdUd5Z*ee(dVdWd5Z+e,Z-edXd!œdYdZ„ƒZ,e.e.fZ/d[ed\<ejdkd d9d dd]œd^d_„ƒZ0ejdld d d dXd]œd`d_„ƒZ0dmd d d dXd]œdad_„Z0dbddcœddde„Z1‡Z2S)nraíRepresents an incoming WSGI HTTP request, with headers and body
    taken from the WSGI environment. Has properties and methods for
    using the functionality defined by various HTTP specs. The data in
    requests object is read-only.
 
    Text data is assumed to use UTF-8 encoding, which should be true for
    the vast majority of modern clients. Using an encoding set by the
    client is unsafe in Python due to extra encodings it provides, such
    as ``zip``. To change the assumed encoding, subclass and replace
    :attr:`charset`.
 
    :param environ: The WSGI environ is generated by the WSGI server and
        contains information about the server configuration and client
        request.
    :param populate_request: Add this request object to the WSGI environ
        as ``environ['werkzeug.request']``. Can be useful when
        debugging.
    :param shallow: Makes reading from :attr:`stream` (and any method
        that would read from it) raise a :exc:`RuntimeError`. Useful to
        prevent consuming the form data in middleware, which would make
        it unavailable to the final application.
 
    .. versionchanged:: 2.1
        Old ``BaseRequest`` and mixin classes were removed.
 
    .. versionchanged:: 2.1
        Remove the ``disable_data_descriptor`` attribute.
 
    .. versionchanged:: 2.0
        Combine ``BaseRequest`` and mixins into a single ``Request``
        class.
 
    .. versionchanged:: 0.5
        Read-only mode is enforced with immutable classes for all data.
    Nz
int | NoneÚmax_content_lengthÚmax_form_memory_sizeièztype[FormDataParser]Úform_data_parser_classrÚenvironÚboolÚshallowTFÚNone)rÚpopulate_requestrÚreturnc s†tƒj| dd¡| dd¡t|ƒt| d¡p.dƒt| d¡p>dƒ| dd¡ d    ¡t|ƒ| d
¡d ||_||_|r‚|s‚||jd <dS) NÚREQUEST_METHODÚGETzwsgi.url_schemeÚhttpZ SCRIPT_NAMEÚZ    PATH_INFOÚ QUERY_STRINGÚlatin1Z REMOTE_ADDR)ÚmethodÚschemeÚserverÚ    root_pathÚpathZ query_stringÚheadersZ remote_addrzwerkzeug.request)    ÚsuperÚ__init__ÚgetrrÚencoderrr)Úselfrrr©Ú    __class__©úPd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/wrappers/request.pyr.is
 
ø
zRequest.__init__zt.Any)ÚargsÚkwargsr cOsRddlm}| dt|jtƒs$|jnd¡|||Ž}z| |¡W¢S| ¡XdS)aCreate a new request object based on the values provided.  If
        environ is given missing values are filled from there.  This method is
        useful for small scripts when you need to simulate a request from an URL.
        Do not use this method for unittesting, there is a full featured client
        object (:class:`Client`) that allows to create multipart requests,
        support for cookies etc.
 
        This accepts the same options as the
        :class:`~werkzeug.test.EnvironBuilder`.
 
        .. versionchanged:: 0.5
           This method now accepts the same arguments as
           :class:`~werkzeug.test.EnvironBuilder`.  Because of this the
           `environ` parameter is now called `environ_overrides`.
 
        :return: request object
        r)ÚEnvironBuilderÚcharsetN)Útestr8Ú
setdefaultÚ
isinstancer9ÚpropertyÚcloseÚ get_request)Úclsr6r7r8Zbuilderr4r4r5Ú from_valuess ÿ
zRequest.from_valuesz&t.Callable[[Request], WSGIApplication]r)Úfr cs2ddlm‰t ˆ¡‡‡‡fdd„ƒ}t d|¡S)amDecorate a function as responder that accepts the request as
        the last argument.  This works like the :func:`responder`
        decorator but the function is passed the request object as the
        last argument and the request object will be closed
        automatically::
 
            @Request.application
            def my_wsgi_app(request):
                return Response('Hello World!')
 
        As of Werkzeug 0.14 HTTP exceptions are automatically caught and
        converted to responses instead of failing.
 
        :param f: the WSGI callable to decorate
        :return: a new WSGI callable
        r)Ú HTTPExceptionc s„ˆ|dƒ}|jzˆ|dd…|fŽ}Wn0ˆk
r\}z| |d¡}W5d}~XYnX||dd…ŽW5QR£SQRXdS)Néþÿÿÿ)Z get_response)r6ÚrequestÚrespÚe©rCr@rBr4r5Ú application·s  z(Request.application.<locals>.applicationr)Ú
exceptionsrCÚ    functoolsÚwrapsÚtÚcast)r@rBrIr4rHr5rIs     zRequest.applicationz
str | Nonez t.IO[bytes])Útotal_content_lengthÚ content_typeÚfilenameÚcontent_lengthr cCst||||dS)aàCalled to get a stream for the file upload.
 
        This must provide a file-like class with `read()`, `readline()`
        and `seek()` methods that is both writeable and readable.
 
        The default implementation returns a temporary file if the total
        content length is higher than 500KB.  Because many browsers do not
        provide a content length for the files only the total content
        length matters.
 
        :param total_content_length: the total content length of all the
                                     data in the request combined.  This value
                                     is guaranteed to be there.
        :param content_type: the mimetype of the uploaded file.
        :param filename: the filename of the uploaded file.  May be `None`.
        :param content_length: the length of this file.  This value is usually
                               not provided because webbrowsers do not provide
                               this value.
        )rOrQrPrRr)r1rOrPrQrRr4r4r5Ú_get_file_streamÃs üzRequest._get_file_stream)r cCst|j d¡ƒS)z–``True`` if the request method carries content. By default
        this is true if a ``Content-Type`` is sent.
 
        .. versionadded:: 0.8
        Ú CONTENT_TYPE)rrr/©r1r4r4r5Úwant_form_data_parsedäszRequest.want_form_data_parsedrc    CsJ|jdkr|jnd}|jdkr$|jnd}|j|j|||j|j|j|jdS)z“Creates the form data parser. Instantiates the
        :attr:`form_data_parser_class` with some parameters.
 
        .. versionadded:: 0.8
        zutf-8NÚreplace)Zstream_factoryr9ÚerrorsrrÚmax_form_partsr@)Ú_charsetÚ_encoding_errorsrrSrrrYÚparameter_storage_class)r1r9rXr4r4r5Úmake_form_data_parserísùzRequest.make_form_data_parsercCsld|jkrdS|jr8| ¡}| | ¡|j|j|j¡}n|j|     ¡|     ¡f}|j}|\|d<|d<|d<dS)auMethod used internally to retrieve submitted data.  After calling
        this sets `form` and `files` on the request object to multi dicts
        filled with the incoming form data.  As a matter of fact the input
        stream will be empty afterwards.  You can also call this method to
        force the parsing of the form data.
 
        .. versionadded:: 0.8
        ÚformNÚstreamÚfiles)
Ú__dict__rVr]ÚparseÚ_get_stream_for_parsingÚmimetyperRZmimetype_paramsr_r\)r1ÚparserÚdataÚdr4r4r5Ú_load_form_dataÿs 
 
üýzRequest._load_form_datacCs"t|ddƒ}|dk    rt|ƒS|jS)zïThis is the same as accessing :attr:`stream` with the difference
        that if it finds cached data from calling :meth:`get_data` first it
        will create a new stream out of the cached data.
 
        .. versionadded:: 0.9.3
        Ú _cached_dataN)Úgetattrrr_)r1Z cached_datar4r4r5rc s zRequest._get_stream_for_parsingcCs.|j d¡}t|pdƒD]\}}| ¡qdS)zñCloses associated resources of this request object.  This
        closes all file handles explicitly.  You can also use the request
        object in a with statement which will automatically close it.
 
        .. versionadded:: 0.9
        r`r4N)rar/r
r>)r1r`Ú_keyÚvaluer4r4r5r>,s z Request.closecCs|S©Nr4rUr4r4r5Ú    __enter__7szRequest.__enter__cCs | ¡dSrm)r>)r1Úexc_typeÚ    exc_valueÚtbr4r4r5Ú__exit__:szRequest.__exit__cCs|jrtdƒ‚t|j|jdS)añThe WSGI input stream, with safety checks. This stream can only be consumed
        once.
 
        Use :meth:`get_data` to get the full data as bytes or text. The :attr:`data`
        attribute will contain the full bytes only if they do not represent form data.
        The :attr:`form` attribute will contain the parsed form data in that case.
 
        Unlike :attr:`input_stream`, this stream guards against infinite streams or
        reading past :attr:`content_length` or :attr:`max_content_length`.
 
        If ``max_content_length`` is set, it can be enforced on streams if
        ``wsgi.input_terminated`` is set. Otherwise, an empty stream is returned.
 
        If the limit is reached before the underlying stream is exhausted (such as a
        file that is too large, or an infinite stream), the remaining contents of the
        stream cannot be read safely. Depending on how the server handles this, clients
        may show a "connection reset" failure instead of seeing the 413 response.
 
        .. versionchanged:: 2.3
            Check ``max_content_length`` preemptively and while reading.
 
        .. versionchanged:: 0.9
            The stream is always set (but may be consumed) even if form parsing was
            accessed first.
        zXThis request was created with 'shallow=True', reading from the input stream is disabled.)r)rÚ RuntimeErrorrrrrUr4r4r5r_=sÿÿzRequest.streamz
wsgi.inputzÿThe raw WSGI input stream, without any safety checks.
 
        This is dangerous to use. It does not guard against infinite streams or reading
        past :attr:`content_length` or :attr:`max_content_length`.
 
        Use :attr:`stream` instead.
        )ÚdocÚbytescCs |jddS)z¾The raw data read from :attr:`stream`. Will be empty if the request
        represents form data.
 
        To get the raw data even if it represents form data, use :meth:`get_data`.
        T)Úparse_form_data)Úget_datarUr4r4r5rfmsz Request.datazt.Literal[False])ÚcacheÚas_textrvr cCsdSrmr4©r1rxryrvr4r4r5rwvszRequest.get_data.zt.Literal[True]ÚstrcCsdSrmr4rzr4r4r5rwsz bytes | strcCsLt|ddƒ}|dkr4|r | ¡|j ¡}|r4||_|rH| |j|j¡}|S)aÐThis reads the buffered incoming data from the client into one
        bytes object.  By default this is cached but that behavior can be
        changed by setting `cache` to `False`.
 
        Usually it's a bad idea to call this method without checking the
        content length first as a client could send dozens of megabytes or more
        to cause memory problems on the server.
 
        Note that if the form data was already parsed this method will not
        return anything as form data parsing does not cache the data like
        this method does.  To implicitly invoke form data parsing function
        set `parse_form_data` to `True`.  When this is done the return value
        of this method will be an empty string if the form parser handles
        the data.  This generally is not necessary as if the whole data is
        cached (which is the default) the form parser will used the cached
        data to parse the form data.  Please be generally aware of checking
        the content length first in any case before calling this method
        to avoid exhausting server memory.
 
        If `as_text` is set to `True` the return value will be a decoded
        string.
 
        .. versionadded:: 0.9
        riN)rjrhr_ÚreadriÚdecoderZr[)r1rxryrvÚrvr4r4r5rwˆs 
zImmutableMultiDict[str, str]cCs| ¡|jS)aDThe form parameters.  By default an
        :class:`~werkzeug.datastructures.ImmutableMultiDict`
        is returned from this function.  This can be changed by setting
        :attr:`parameter_storage_class` to a different type.  This might
        be necessary if the order of the form data is important.
 
        Please keep in mind that file uploads will not end up here, but instead
        in the :attr:`files` attribute.
 
        .. versionchanged:: 0.9
 
            Previous to Werkzeug 0.9 this would only contain form data for POST
            and PUT requests.
        )rhr^rUr4r4r5r^®sz Request.formzCombinedMultiDict[str, str]cCsP|jg}|jdkr| |j¡g}|D] }t|tƒs<t|ƒ}| |¡q&t|ƒS)aA :class:`werkzeug.datastructures.CombinedMultiDict` that
        combines :attr:`args` and :attr:`form`.
 
        For GET requests, only ``args`` are present, not ``form``.
 
        .. versionchanged:: 2.0
            For GET requests, only ``args`` are present, not ``form``.
        r")r6r'Úappendr^r<r r)r1Úsourcesr6rgr4r4r5ÚvaluesÁs
 
 
 zRequest.valuesz$ImmutableMultiDict[str, FileStorage]cCs| ¡|jS)a»:class:`~werkzeug.datastructures.MultiDict` object containing
        all uploaded files.  Each key in :attr:`files` is the name from the
        ``<input type="file" name="">``.  Each value in :attr:`files` is a
        Werkzeug :class:`~werkzeug.datastructures.FileStorage` object.
 
        It basically behaves like a standard file object you know from Python,
        with the difference that it also has a
        :meth:`~werkzeug.datastructures.FileStorage.save` function that can
        store the file on the filesystem.
 
        Note that :attr:`files` will only contain data if the request method was
        POST, PUT or PATCH and the ``<form>`` that posted to the request had
        ``enctype="multipart/form-data"``.  It will be empty otherwise.
 
        See the :class:`~werkzeug.datastructures.MultiDict` /
        :class:`~werkzeug.datastructures.FileStorage` documentation for
        more details about the used data structure.
        )rhr`rUr4r4r5r`Þsz Request.filescCs|jS)zgAlias for :attr:`self.root_path`. ``environ["SCRIPT_ROOT"]``
        without a trailing slash.
        )r*rUr4r4r5Ú script_rootõszRequest.script_rootcCs|jS)zAlias for :attr:`root_url`. The URL with scheme, host, and
        root path. For example, ``https://example.com/app/``.
        )Zroot_urlrUr4r4r5Úurl_rootüszRequest.url_rootZ REMOTE_USERzœIf the server supports user authentication, and the
        script is protected, this attribute contains the username the
        user has authenticated as.zwsgi.multithreadz[boolean that is `True` if the application is served by a
        multithreaded WSGI server.zwsgi.multiprocesszlboolean that is `True` if the application is served by a
        WSGI server that spawns multiple processes.z wsgi.run_oncezÜboolean that is `True` if the application will be
        executed only once in a process lifetime.  This is the case for
        CGI for example, but it's not guaranteed that the execution only
        happens one time.z t.Any | NonecCs| ¡S)aãThe parsed JSON data if :attr:`mimetype` indicates JSON
        (:mimetype:`application/json`, see :attr:`is_json`).
 
        Calls :meth:`get_json` with default arguments.
 
        If the request content type is not ``application/json``, this
        will raise a 415 Unsupported Media Type error.
 
        .. versionchanged:: 2.3
            Raise a 415 error instead of 400.
 
        .. versionchanged:: 2.1
            Raise a 400 error if the content type is incorrect.
        )Úget_jsonrUr4r4r5Újson!sz Request.jsonztuple[t.Any, t.Any]Ú _cached_json)ÚforceÚsilentrxr cCsdSrmr4©r1r‡rˆrxr4r4r5r„7szRequest.get_jsoncCsdSrmr4r‰r4r4r5r„=sc
 
CsÎ|r|j|tk    r|j|S|s8|js8|s4| d¡SdS|j|d}z|j |¡}Wnftk
rº}zH|rˆd}|rª|j\}}||f|_n"| |¡}|rª|j\}}    ||    f|_W5d}~XYnX|rÊ||f|_|S)aParse :attr:`data` as JSON.
 
        If the mimetype does not indicate JSON
        (:mimetype:`application/json`, see :attr:`is_json`), or parsing
        fails, :meth:`on_json_loading_failed` is called and
        its return value is used as the return value. By default this
        raises a 415 Unsupported Media Type resp.
 
        :param force: Ignore the mimetype and always try to parse JSON.
        :param silent: Silence mimetype and parsing errors, and
            return ``None`` instead.
        :param cache: Store the parsed JSON to return for subsequent
            calls.
 
        .. versionchanged:: 2.3
            Raise a 415 error instead of 400.
 
        .. versionchanged:: 2.1
            Raise a 400 error if the content type is incorrect.
        N)rx)r†ÚEllipsisZis_jsonÚon_json_loading_failedrwÚ json_moduleÚloadsÚ
ValueError)
r1r‡rˆrxrfr~rGZ    normal_rvÚ_Z    silent_rvr4r4r5r„Cs,
 
 
 
 
 
 
zValueError | None)rGr cCs"|dk    rtd|›ƒ‚tdƒ‚dS)aÒCalled if :meth:`get_json` fails and isn't silenced.
 
        If this method returns a value, it is used as the return value
        for :meth:`get_json`. The default implementation raises
        :exc:`~werkzeug.exceptions.BadRequest`.
 
        :param e: If parsing failed, this is the exception. It will be
            ``None`` if the content type wasn't ``application/json``.
 
        .. versionchanged:: 2.3
            Raise a 415 error instead of 400.
        NzFailed to decode JSON object: z^Did not attempt to load JSON data because the request Content-Type was not 'application/json'.)r r )r1rGr4r4r5r‹zs
ÿzRequest.on_json_loading_failed)TF)NN)TFF)T.F)TFF)...)...)FFT)3Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚ__annotations__rrYrrr.Ú classmethodrArIrSr=rVr]rhrcr>rnrrrr_rrMÚIOruZ input_streamrfÚoverloadrwr^rr`r‚rƒr{Z remote_userrZis_multithreadZis_multiprocessZ is_run_oncer…rŒrŠr†r„r‹Ú __classcell__r4r4r2r5rs¸
+       ü)û!!  $ þ üü    ÿ&þþþþ ÿÿÿ7r)$Ú
__future__rrKr…ÚtypingrMÚiorÚ    _internalrZdatastructuresrrrr    r
r rJr r Z
formparserrrZsansio.requestrZ_SansIORequestÚutilsrrZwsgirrÚ TYPE_CHECKINGZ_typeshed.wsgirrr4r4r4r5Ú<module>s0