Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/werkzeug/__pycache__/wsgi.cpython-37.pyc

508 lines
30 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]j<><00>@s<>dZddlZddlZddlmZddlmZddlmZddlm Z ddlm
Z
dd lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdd<16>ZdJdd<19>Zdd<1B>ZdKdd<1D>Zdd<1F>ZdLd!d"<22>Zd#d$<24>ZdMd'd(<28>Z dNd)d*<2A>Z!dOd+d,<2C>Z"dPd-d.<2E>Z#dQd0d1<64>Z$e
Gd2d3<64>d3e%<25><03>Z&dRd5d6<64>Z'e
Gd7d8<64>d8e%<25><03>Z(e
Gd9d:<3A>d:e%<25><03>Z)d;d<<3C>Z*dSd>d?<3F>Z+dTd@dA<64>Z,e
GdBdC<64>dCej-<2D><03>Z.ddDl/m0Z0e0e1dEgdFgdGgdH<64>dI<64>dS)Uz<55>
werkzeug.wsgi
~~~~~~~~~~~~~
This module implements WSGI related helpers.
:copyright: 2007 Pallets
:license: BSD-3-Clause
<EFBFBD>N)<01>partial)<01>update_wrapper)<01>chain<69>)<01>BytesIO)<01>implements_iterator)<01>make_literal_wrapper)<01> string_types)<01> text_type)<01>to_bytes)<01>
to_unicode)<01>try_coerce_native)<01>wsgi_get_bytes)<01> _encode_idna)<01>
uri_to_iri)<01>url_join)<01> url_parse)<01> url_quotecst<00>fdd<02><08><00>S)a
Marks a function as responder. Decorate a function with it and it
will automatically call the return value as WSGI application.
Example::
@responder
def application(environ, start_response):
return Response('Hello World!')
cs<00>|<00>|dd<00><00>S)N<><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<01>a)<01>fr<00>3/tmp/pip-install-c3kgu56x/Werkzeug/werkzeug/wsgi.py<70><lambda>+<00>zresponder.<locals>.<lambda>)r)rr)rr<00> responder!s
rFcCs<>|ddt||<04>g}|j}|r0td<03>|<05>d<00>S|tt|<00>dd<03><02><01><01>d<04><01>|d<04>|s<>|tt|<00>dd<03><02><01>d<07><01><01>|s<>t |<00>}|r<>|d|<00>td<03>|<05><01>S) a<>A handy helper function that recreates the full URL as IRI for the
current request or parts of it. Here's an example:
>>> from werkzeug.test import create_environ
>>> env = create_environ("/?param=foo", "http://localhost/script")
>>> get_current_url(env)
'http://localhost/script/?param=foo'
>>> get_current_url(env, root_only=True)
'http://localhost/script/'
>>> get_current_url(env, host_only=True)
'http://localhost/'
>>> get_current_url(env, strip_querystring=True)
'http://localhost/script/'
This optionally it verifies that the host is in a list of trusted hosts.
If the host is not in there it will raise a
:exc:`~werkzeug.exceptions.SecurityError`.
Note that the string returned might contain unicode characters as the
representation is an IRI not an URI. If you need an ASCII only
representation you can use the :func:`~werkzeug.urls.iri_to_uri`
function:
>>> from werkzeug.urls import iri_to_uri
>>> iri_to_uri(get_current_url(env))
'http://localhost/script/?param=foo'
:param environ: the WSGI environment to get the current URL from.
:param root_only: set `True` if you only want the root URL.
:param strip_querystring: set to `True` if you don't want the querystring.
:param host_only: set to `True` if the host URL should be returned.
:param trusted_hosts: a list of trusted hosts, see :func:`host_is_trusted`
for more information.
zwsgi.url_schemez://<2F><00>/<2F> SCRIPT_NAME<4D> PATH_INFO<46>/<2F>?)
<EFBFBD>get_host<73>appendr<00>joinrr<00>get<65>rstrip<69>lstrip<69>get_query_string)<08>environ<6F> root_onlyZstrip_querystringZ host_only<6C> trusted_hosts<74>tmp<6D>cat<61>qsrrr<00>get_current_url.s) r/c Cs<>|sdSt|t<01>r|g}dd<03>}y ||<00>}Wntk
r@dSXxp|D]h}|<03>d<04>rh|dd<06>}d}nd}y ||<03>}Wntk
r<EFBFBD>dSX||kr<>dS|rH|<00>d|<00>rHdSqHWdS) ahChecks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname starts with a dot it will match against
all subdomains as well.
FcSs d|kr|<00>dd<02>d}t|<00>S)N<>:rr)<02>rsplitr)<01>hostnamerrr<00>
_normalizewsz#host_is_trusted.<locals>._normalize<7A>.rNT<4E>.)<05>
isinstancer <00> UnicodeError<6F>
startswith<EFBFBD>endswith)r2Z trusted_listr3<00>refZ suffix_matchrrr<00>host_is_trustedfs. 
 

  r;cCs<>d|krX|d}|ddkr4|<02>d<04>r4|dd<06>}q<>|ddkr<>|<02>d<08>r<>|dd <09>}n,|d
}|d|d fd kr<>|d |d 7}|dk r<>t||<01>s<>ddlm}|d|<00><01>|S)a<>Return the host for the given WSGI environment. This first checks
the ``Host`` header. If it's not present, then ``SERVER_NAME`` and
``SERVER_PORT`` are used. The host will only contain the port if it
is different than the standard port for the protocol.
Optionally, verify that the host is trusted using
:func:`host_is_trusted` and raise a
:exc:`~werkzeug.exceptions.SecurityError` if it is not.
:param environ: The WSGI environment to get the host from.
:param trusted_hosts: A list of trusted hosts.
:return: Host, with port if necessary.
:raise ~werkzeug.exceptions.SecurityError: If the host is not
trusted.
Z HTTP_HOSTzwsgi.url_scheme<6D>httpz:80N<30><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>httpsz:443<34><33><EFBFBD><EFBFBD><EFBFBD>Z SERVER_NAMEZ SERVER_PORT))r><00>443)r<<00>80r0r)<01> SecurityErrorzHost "%s" is not trusted)r9r;<00>
exceptionsrB)r)r+<00>rvrBrrrr"<00>s
  r"c CsR|<00>dd<02>dkrdS|<00>d<05>}|dk rNytdt|<01><01>Sttfk
rLYnXdS)aReturns the content length from the WSGI environment as
integer. If it's not available or chunked transfer encoding is used,
``None`` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from.
ZHTTP_TRANSFER_ENCODINGr<00>chunkedN<64>CONTENT_LENGTHr)r%<00>max<61>int<6E>
ValueError<EFBFBD> TypeError)r)<00>content_lengthrrr<00>get_content_length<74>s 
rLTcCs>|d}t|<00>}|<00>d<02>r|S|dkr4|r0t<02>S|St||<03>S)a
Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
If content length is not set, the stream will be empty for safety reasons.
If the WSGI server supports chunked or infinite streams, it should set
the ``wsgi.input_terminated`` value in the WSGI environ to indicate that.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the stream from.
:param safe_fallback: use an empty stream as a safe fallback when the
content length is not set. Disabling this allows infinite streams,
which can be a denial-of-service risk.
z
wsgi.inputzwsgi.input_terminatedN)rLr%r<00> LimitedStream)r)Z safe_fallback<63>streamrKrrr<00>get_input_stream<61>s
rOcCs t|<00>dd<02><02>}tt|dd<04><02>S)aNReturns the `QUERY_STRING` from the WSGI environment. This also takes
care about the WSGI decoding dance on Python 3 environments as a
native string. The string returned will be restricted to ASCII
characters.
.. versionadded:: 0.9
:param environ: the WSGI environment object to get the query string from.
<20> QUERY_STRINGrz :&%=+$!*'(),)<01>safe)rr%r r)r)r.rrrr(<00>s
r(<00>utf-8<>replacecCs t|<00>dd<02><02>}t|||dd<04>S)a<>Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0.9
:param environ: the WSGI environment object to get the path from.
:param charset: the charset for the path info, or `None` if no
decoding should be performed.
:param errors: the decoding error handling.
rrT)<01>allow_none_charset)rr%r )r)<00>charset<65>errors<72>pathrrr<00> get_path_info<66>s rXcCs t|<00>dd<02><02>}t|||dd<04>S)a<>Returns the `SCRIPT_NAME` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0.9
:param environ: the WSGI environment object to get the path from.
:param charset: the charset for the path, or `None` if no
decoding should be performed.
:param errors: the decoding error handling.
rrT)rT)rr%r )r)rUrVrWrrr<00>get_script_names rYcCs<>|<00>d<01>}|sdS|<00>dd<04>}|}|<03>d<05>}||krL|dt|<05>t|<03>7}d|krrd|d<|||d<t|<03>}n0|<03>dd<06>\}}d||d<|||d<t|<07>}t|||dd<08>S) a<>Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/foo//bar``) these are ignored but
properly pushed to the `SCRIPT_NAME`:
>>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
>>> pop_path_info(env)
'a'
>>> env['SCRIPT_NAME']
'/foo/a'
>>> pop_path_info(env)
'b'
>>> env['SCRIPT_NAME']
'/foo/a/b'
.. versionadded:: 0.5
.. versionchanged:: 0.9
The path is now decoded and a charset and encoding
parameter can be provided.
:param environ: the WSGI environment that is modified.
rNrrrrT)rT)r%r'<00>lenr<00>splitr )r)rUrVrW<00> script_name<6D>old_pathrD<00>segmentrrr<00> pop_path_info!s"
 
 
  r_cCs:|<00>dd<02><02>d<03><01>dd<04>}|r6tt|d<00>||dd<07>SdS) a-Returns the next segment on the `PATH_INFO` or `None` if there
is none. Works like :func:`pop_path_info` without modifying the
environment:
>>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
>>> peek_path_info(env)
'a'
>>> peek_path_info(env)
'a'
If the `charset` is set to `None` a bytestring is returned.
.. versionadded:: 0.5
.. versionchanged:: 0.9
The path is now decoded and a charset and encoding
parameter can be provided.
:param environ: the WSGI environment that is checked.
rrrrrT)rTN)r%r'r[r r)r)rUrV<00>segmentsrrr<00>peek_path_infoUsra<00>werkzeug.url_quotecCs<>dd<02>}t|||<03>}t|t<02>r*t|dd<04>}t|||<03>}t|<07>dd<06>\}} }
tt||<06><02>dd<06>\} } } ||| <09>} || | <0C>} |r<>x2|| fD]}|dkr<>dSq<>Wn|dkr<>|| ks<>dS| | kr<>dS|
<EFBFBD>d<08>}
| <0A>|
<EFBFBD>s<>dSd| t|
<EFBFBD>d<05><00> d<08>S) a<>Extracts the path info from the given URL (or WSGI environment) and
path. The path info returned is a unicode string, not a bytestring
suitable for a WSGI environment. The URLs might also be IRIs.
If the path info could not be determined, `None` is returned.
Some examples:
>>> extract_path_info('http://example.com/app', '/app/hello')
u'/hello'
>>> extract_path_info('http://example.com/app',
... 'https://example.com/app/hello')
u'/hello'
>>> extract_path_info('http://example.com/app',
... 'https://example.com/app/hello',
... collapse_http_schemes=False) is None
True
Instead of providing a base URL you can also pass a WSGI environment.
:param environ_or_baseurl: a WSGI environment dict, a base URL or
base IRI. This is the root of the
application.
:param path_or_url: an absolute path from the server root, a
relative path (in which case it's the path info)
or a full URL. Also accepts IRIs and unicode
parameters.
:param charset: the charset for byte data in URLs
:param errors: the error handling on decode
:param collapse_http_schemes: if set to `False` the algorithm does
not assume that http and https on the
same server point to the same
resource.
.. versionchanged:: 0.15
The ``errors`` parameter defaults to leaving invalid bytes
quoted instead of replacing them.
.. versionadded:: 0.6
cSsv|<01>dd<02>d<00>dd<02>}t|<02>dkrR|\}}|dkr<|dksL|dkr^|d kr^d}n |d
}d}|dk rr|d|7}|S) N<>@r<00><><EFBFBD><EFBFBD><EFBFBD>r0<00>r<rAr>r@r)r[rZ)<04>scheme<6D>netloc<6F>parts<74>portrrr<00>_normalize_netloc<6F>s  z,extract_path_info.<locals>._normalize_netlocT)r*N<>)r<r>r)
rr6<00>dictr/rrr&r8rZr')Zenviron_or_baseurlZ path_or_urlrUrVZcollapse_http_schemesrjrWZbase_iriZ base_schemeZ base_netloc<6F> base_pathZ
cur_schemeZ
cur_netlocZcur_pathrfrrr<00>extract_path_infoqs*0 
  




rnc@s2eZdZdZd dd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>ZdS) <0C>ClosingIteratoraAThe WSGI specification requires that all middlewares and gateways
respect the `close` callback of the iterable returned by the application.
Because it is useful to add another close action to a returned iterable
and adding a custom iterable is a boring task this class can be used for
that::
return ClosingIterator(app(environ, start_response), [cleanup_session,
cleanup_locals])
If there is just one close function it can be passed instead of the list.
A closing iterator is not needed if the application uses response objects
and finishes the processing if the response is started::
try:
return response(environ, start_response)
finally:
cleanup_session()
cleanup_locals()
NcCs`t|<01>}tt|<03>|_|dkr"g}nt|<02>r2|g}nt|<02>}t|dd<00>}|rV|<02>d|<04>||_dS)N<>closer) <09>iterr<00>next<78>_next<78>callable<6C>list<73>getattr<74>insert<72>
_callbacks)<05>self<6C>iterable<6C> callbacks<6B>iteratorZiterable_closerrr<00>__init__<5F>s   zClosingIterator.__init__cCs|S)Nr)ryrrr<00>__iter__<5F>szClosingIterator.__iter__cCs|<00><00>S)N)rs)ryrrr<00>__next__<5F>szClosingIterator.__next__cCsx|jD]
}|<01>qWdS)N)rx)ry<00>callbackrrrrp<00>s zClosingIterator.close)N)<08>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r}r~rrprrrrro<00>s

ro<00> cCs|<00>dt<01>||<02>S)a<>Wraps a file. This uses the WSGI server's file wrapper if available
or otherwise the generic :class:`FileWrapper`.
.. versionadded:: 0.5
If the file wrapper from the WSGI server is used it's important to not
iterate over it from inside the application but to pass it through
unchanged. If you want to pass out a file wrapper inside a response
object you have to set :attr:`~BaseResponse.direct_passthrough` to `True`.
More information about file wrappers are available in :pep:`333`.
:param file: a :class:`file`-like object with a :meth:`~file.read` method.
:param buffer_size: number of bytes for one iteration.
zwsgi.file_wrapper)r%<00> FileWrapper)r)<00>file<6C> buffer_sizerrr<00> wrap_filesr<>c@sJeZdZdZddd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Zd d<0E>Z dd<10>Z
dS)r<>a`This class can be used to convert a :class:`file`-like object into
an iterable. It yields `buffer_size` blocks until the file is fully
read.
You should not use this class directly but rather use the
:func:`wrap_file` function that uses the WSGI server's file wrapper
support if it's available.
.. versionadded:: 0.5
If you're using this object together with a :class:`BaseResponse` you have
to use the `direct_passthrough` mode.
:param file: a :class:`file`-like object with a :meth:`~file.read` method.
:param buffer_size: number of bytes for one iteration.
<20> cCs||_||_dS)N)r<>r<>)ryr<>r<>rrrr}'szFileWrapper.__init__cCst|jd<01>r|j<01><02>dS)Nrp)<03>hasattrr<72>rp)ryrrrrp+s zFileWrapper.closecCs*t|jd<01>r|j<01><02>St|jd<02>r&dSdS)N<>seekable<6C>seekTF)r<>r<>r<>)ryrrrr<>/s
 
 zFileWrapper.seekablecGst|jd<01>r|jj|<01>dS)Nr<4E>)r<>r<>r<>)ry<00>argsrrrr<>6s zFileWrapper.seekcCst|jd<01>r|j<01><02>SdS)N<>tell)r<>r<>r<>)ryrrrr<>:s 
zFileWrapper.tellcCs|S)Nr)ryrrrr~?szFileWrapper.__iter__cCs |j<00>|j<02>}|r|St<03><00>dS)N)r<><00>readr<64><00> StopIteration)ry<00>datarrrrBszFileWrapper.__next__N)r<>) r<>r<>r<>r<>r}rpr<>r<>r<>r~rrrrrr<>s
r<>c@sJeZdZdZddd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Zdd<0F>Z dd<11>Z
dS)<13> _RangeWrapperawThis class can be used to convert an iterable object into
an iterable that will only yield a piece of the underlying content.
It yields blocks until the underlying stream range is fully read.
The yielded blocks will have a size that can't exceed the original
iterator defined block size, but that can be smaller.
If you're using this object together with a :class:`BaseResponse` you have
to use the `direct_passthrough` mode.
:param iterable: an iterable object with a :meth:`__next__` method.
:param start_byte: byte from which read will start.
:param byte_range: how many bytes to read.
rNcCsVt|<01>|_||_||_d|_|dk r2|j|j|_d|_t|d<02>oH|<01><07>|_d|_dS)Nrr<>F) rqrz<00>
byte_range<EFBFBD>
start_byte<EFBFBD>end_byte<74> read_lengthr<68>r<><00> end_reached)ryrzr<>r<>rrrr}[s
z_RangeWrapper.__init__cCs|S)Nr)ryrrrr~fsz_RangeWrapper.__iter__cCsBy t|j<01>}|jt|<01>7_|Stk
r<d|_<05>YnXdS)NT)rrrzr<>rZr<>r<>)ry<00>chunkrrr<00> _next_chunkis
z_RangeWrapper._next_chunkcCspd}|jr,|j<01>|j<03>|j<01><04>|_|j}n<x|j|jkrD|<00><06>}q.W|dk rb||j|jd<00>}|j}||fS)N)r<>rzr<>r<>r<>r<>r<>)ryr<><00>contextual_read_lengthrrr<00>_first_iterationrs  z_RangeWrapper._first_iterationcCsn|jr t<01><00>d}|j}|jdkr,|<00><03>\}}|dkr<|<00><04>}|jdk rj|j|jkrjd|_|d|j|<00>S|S)NrT)r<>r<>r<>r<>r<>r<>)ryr<>r<>rrrrs<00>s
 z_RangeWrapper._nextcCs |<00><00>}|r|Sd|_t<02><00>dS)NT)rsr<>r<>)ryr<>rrrr<00>s
z_RangeWrapper.__next__cCst|jd<01>r|j<01><02>dS)Nrp)r<>rzrp)ryrrrrp<00>s z_RangeWrapper.close)rN) r<>r<>r<>r<>r}r~r<>r<>rsrrprrrrr<>Is
 r<>ccs~t|tttf<03>rtd<01><01>t|d<02>s>x|D]}|r(|Vq(WdSt|t<06>sZ|dk rZt||<01>}|j}x||<02>}|spP|VqbWdS)z-Helper for the line and chunk iter functions.zBPassed a string or byte object instead of true iterator or stream.r<>N)r6<00>bytes<65> bytearrayr
rJr<>rMr<>)rN<00>limitr<74><00>item<65>_readrrr<00>_make_chunk_iter<65>s 



r<><00>(c #s<>t||<01><01><03>t<01>d<01>}|sdSt|<04>}|d<01><01>|d<03>}|d<04>}|d<05><01>t|f<01><00><02><00><00><01><02><03>fdd<07>}<08>} x@|<08>D]6}
|
|kr<>| dd<02>|kr<>| |
7} <09>}
| r<>| V|
} qrW| r<>| VdS) a<>Safely iterates line-based over an input stream. If the input stream
is not a :class:`LimitedStream` the `limit` parameter is mandatory.
This uses the stream's :meth:`~file.read` method internally as opposite
to the :meth:`~file.readline` method that is unsafe and can only be used
in violation of the WSGI specification. The same problem applies to the
`__iter__` function of the input stream which calls :meth:`~file.readline`
without arguments.
If you need line-by-line processing it's strongly recommended to iterate
over the input stream using this helper function.
.. versionchanged:: 0.8
This function now ensures that the limit was reached.
.. versionadded:: 0.9
added support for iterators as input stream.
.. versionadded:: 0.11.10
added support for the `cap_at_buffer` parameter.
:param stream: the stream or iterate to iterate over.
:param limit: the limit in bytes for the stream. (Usually
content length. Not necessary if the `stream`
is a :class:`LimitedStream`.
:param buffer_size: The optional buffer size.
:param cap_at_buffer: if this is set chunks are split if they are longer
than the buffer size. Internally this is implemented
that the buffer size might be exhausted by a factor
of two however.
rN<> <0A>
z
c3s<><00>j}g}x<>t<01>d<01>}|sPg}d}x<>t||<02>d<03><01>D]<5D>}|<03>|<05>|t|<05>7}|rt|dd<00><00>krt||<03>Vg}q6<71>r6|<04>kr6||<03>}x*t|<06><01>kr<>|d<00><01>V|<06>d<00>}q<>W|g}q6W|}q W|r<>||<01>VdS)NrrTrd)r$rrr<00>
splitlinesr#rZ)<07>_join<69>buffer<65>new_data<74>new_buf<75>buf_sizer<65>rD)<05>_iterr<72><00> cap_at_buffer<65>crlf<6C>emptyrr<00>_iter_basic_lines<65>s.

 
 
z)make_line_iter.<locals>._iter_basic_linesrd)r<>rrrr) rNr<>r<>r<><00>
first_item<EFBFBD>sZcr<63>lfr<66><00>previousr<73>r)r<>r<>r<>r<>r<>r<00>make_line_iter<65>s* 
  r<>ccs\t|||<03>}t|d<01>}|sdSt|f|<05>}t|t<04>rZt|<01>}t<06>dt<06>|<01><00>j }dj
}n(t |<01>}t<06>dt<06>|<01>d<00>j }dj
}g} x<>t|d<01>}
|
s<EFBFBD>P||
<EFBFBD>} g} d} x<>t| | <0B>D]<5D>}||kr<>|| <0C>Vg} d} q<>| t |<0E>7} | <0C> |<0E>|r<>| |kr<>|| <0C>}x.t |<0F>|k<05>r,|d|<03>V||d<02>}<0F>qW|g} t |<0F>} q<>W| } q<>W| <09>rX|| <09>VdS)a Works like :func:`make_line_iter` but accepts a separator
which divides chunks. If you want newline based processing
you should use :func:`make_line_iter` instead as it
supports arbitrary newline markers.
.. versionadded:: 0.8
.. versionadded:: 0.9
added support for iterators as input stream.
.. versionadded:: 0.11.10
added support for the `cap_at_buffer` parameter.
:param stream: the stream or iterate to iterate over.
:param separator: the separator that divides chunks.
:param limit: the limit in bytes for the stream. (Usually
content length. Not necessary if the `stream`
is otherwise already limited).
:param buffer_size: The optional buffer size.
:param cap_at_buffer: if this is set chunks are split if they are longer
than the buffer size. Internally this is implemented
that the buffer size might be exhausted by a factor
of two however.
rNz(%s)<29>(<28>)rr)r<>rrrr6r
r <00>re<72>compile<6C>escaper[r$r rZr#)rN<00> separatorr<72>r<>r<>r<>r<><00>_splitr<74>r<>r<><00>chunksr<73>r<>r<>rDrrr<00>make_chunk_itersJ 
 


 
  r<>c@s|eZdZdZdd<03>Zdd<05>Zedd<07><00>Zdd <09>Zd
d <0B>Z dd d<0E>Z
ddd<11>Z ddd<13>Z ddd<15>Z dd<17>Zdd<19>Zdd<1B>ZdS) rMa<>Wraps a stream so that it doesn't read more than n bytes. If the
stream is exhausted and the caller tries to get more bytes from it
:func:`on_exhausted` is called which by default returns an empty
string. The return value of that function is forwarded
to the reader function. So if it returns an empty string
:meth:`read` will return an empty string as well.
The limit however must never be higher than what the stream can
output. Otherwise :meth:`readlines` will try to read past the
limit.
.. admonition:: Note on WSGI compliance
calls to :meth:`readline` and :meth:`readlines` are not
WSGI compliant because it passes a size argument to the
readline methods. Unfortunately the WSGI PEP is not safely
implementable without a size argument to :meth:`readline`
because there is no EOF marker in the stream. As a result
of that the use of :meth:`readline` is discouraged.
For the same reason iterating over the :class:`LimitedStream`
is not portable. It internally calls :meth:`readline`.
We strongly suggest using :meth:`read` only or using the
:func:`make_line_iter` which safely iterates line-based
over a WSGI input stream.
:param stream: the stream to wrap.
:param limit: the limit for the stream, must not be longer than
what the string can provide if the stream does not
end with `EOF` (like `wsgi.input`)
cCs |j|_|j|_d|_||_dS)Nr)r<>r<><00>readline<6E> _readline<6E>_posr<73>)ryrNr<>rrrr}pszLimitedStream.__init__cCs|S)Nr)ryrrrr~vszLimitedStream.__iter__cCs |j|jkS)z4If the stream is exhausted this attribute is `True`.)r<>r<>)ryrrr<00> is_exhaustedyszLimitedStream.is_exhaustedcCs
|<00>d<01>S)z<>This is called when the stream tries to read past the limit.
The return value of this function is returned from the reading
function.
r)r<>)ryrrr<00> on_exhausted~szLimitedStream.on_exhaustedcCsddlm}|<01><00>dS)aWhat should happen if a disconnect is detected? The return
value of this function is returned from read functions in case
the client went away. By default a
:exc:`~werkzeug.exceptions.ClientDisconnected` exception is raised.
r)<01>ClientDisconnectedN)rCr<>)ryr<>rrr<00> on_disconnect<63>s zLimitedStream.on_disconnect<63>cCs>|j|j}|}x(|dkr8t||<03>}|<00>|<03>||8}qWdS)aExhaust the stream. This consumes all the data left until the
limit is reached.
:param chunk_size: the size for a chunk. It will read the chunk
until the stream is exhausted and throw away
the results.
rN)r<>r<><00>minr<6E>)ry<00>
chunk_size<EFBFBD>to_readr<64>rrr<00>exhaust<73>s  


zLimitedStream.exhaustNc Cs<>|j|jkr|<00><02>S|dks$|dkr*|j}t|j|j|<01>}y|<00>|<02>}Wnttfk
rf|<00><07>SX|r<>t|<03>|kr<>|<00><07>S|jt|<03>7_|S)zyRead `size` bytes or if size is not provided everything is read.
:param size: the number of bytes read.
Nrd) r<>r<>r<>r<>r<><00>IOErrorrIr<>rZ)ry<00>sizer<65>r<>rrrr<><00>s 
zLimitedStream.readc Cs<>|j|jkr|<00><02>S|dkr*|j|j}nt||j|j<00>}y|<00>|<01>}Wnttfk
rf|<00><07>SX|rx|sx|<00><07>S|jt|<02>7_|S)zReads one line from the stream.N) r<>r<>r<>r<>r<>rIr<>r<>rZ)ryr<><00>linerrrr<><00>s 
zLimitedStream.readlinecCst|j}g}|dk r$t|j||<00>}n|j}xD|dk rB|||j8}|j|krNP|<03>|<00>|<01><01>|dk r,|j}q,W|S)z<>Reads a file into a list of strings. It calls :meth:`readline`
until the file is read to the end. It does support the optional
`size` argument if the underlaying stream supports it for
`readline`.
N)r<>r<>r<>r#r<>)ryr<>Zlast_pos<6F>result<6C>endrrr<00> readlines<65>s

zLimitedStream.readlinescCs|jS)zKReturns the position of the stream.
.. versionadded:: 0.9
)r<>)ryrrrr<><00>szLimitedStream.tellcCs|<00><00>}|st<01><00>|S)N)r<>r<>)ryr<>rrrr<00>szLimitedStream.__next__cCsdS)NTr)ryrrr<00>readable<6C>szLimitedStream.readable)r<>)N)N)N)r<>r<>r<>r<>r}r~<00>propertyr<79>r<>r<>r<>r<>r<>r<>r<>rr<>rrrrrMMs!  



rM)<01>_DeprecatedImportModuleZDispatcherMiddlewareZProxyMiddlewareZSharedDataMiddleware)z.middleware.dispatcherz.middleware.http_proxyz.middleware.shared_dataz Werkzeug 1.0)FFFN)N)T)rRrS)rRrS)rRrS)rRrS)rRrbT)r<>)Nr<4E>F)Nr<4E>F)2r<32><00>ior<6F><00> functoolsrr<00> itertoolsr<00>_compatrrrr r
r r r r<00> _internalr<00>urlsrrrrrr/r;r"rLrOr(rXrYr_rarn<00>objectror<>r<>r<>r<>r<>r<><00>IOBaserMZwerkzeugr<67>r<>rrrr<00><module>
sp                 
3+
%
$


4

[ /
 4 P
V
H