a
    NfN                     @  s  d dl mZ d dlZd dlmZ d dlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl"m$Z$ d d!lm%Z% d d"l"m&Z& d d#l"m'Z' d d$l"m(Z( G d%d& d&Z)dS )'    )annotationsN)datetime)	parse_qsl   )Accept)Authorization)CharsetAccept)ETags)Headers)	HeaderSet)IfRange)ImmutableList)ImmutableMultiDict)LanguageAccept)
MIMEAccept)	MultiDict)Range)RequestCacheControl)parse_accept_header)parse_cache_control_header)
parse_date)parse_etags)parse_if_range_header)parse_list_header)parse_options_header)parse_range_header)parse_set_header)	UserAgent)cached_property)header_property   )parse_cookie)get_content_length)get_current_url)get_hostc                
   @  s   e Zd ZU dZeZded< eZded< eZ	ded< e
Zded< d	Zd
ed< dddddddddd	ddZddddZeddddZeddddZeddddZed dd!d"Zeddd#d$Zeddd%d&Zeddd'd(Zeddd)d*Zeddd+d,Zed-dd.d/Zee d0d1d2d3Zed4dd5d6Zee d7d8d2d3Zee d9d:d2d3Z ee d;d<d2d3Z!ed=d	e"d>d2d3Z#ed?d	e$d@d2d3Z%dddAdBZ&edddCdDZ'edEddFdGZ(edHddIdJZ)edKddLdMZ*edNddOdPZ+edQddRdSZ,edTddUdVZ-edWddXdYZ.edZdd[d\Z/edZdd]d^Z0ed_dd`daZ1ed_ddbdcZ2eddddedfZ3edgddhdiZ4edjddkdlZ5edmddndoZ6ee dpdqd2d3Z7edre8dsd2dtZ9ee dudvd2d3Z:ed ddwdxZ;d	S )yRequesta  Represents the non-IO parts of a HTTP request, including the
    method, URL info, and headers.

    This class is not meant for general use. It should only be used when
    implementing WSGI, ASGI, or another HTTP application spec. Werkzeug
    provides a WSGI implementation at :cls:`werkzeug.wrappers.Request`.

    :param method: The method the request was made with, such as
        ``GET``.
    :param scheme: The URL scheme of the protocol the request used, such
        as ``https`` or ``wss``.
    :param server: The address of the server. ``(host, port)``,
        ``(path, None)`` for unix sockets, or ``None`` if not known.
    :param root_path: The prefix that the application is mounted under.
        This is prepended to generated URLs, but is not part of route
        matching.
    :param path: The path part of the URL after ``root_path``.
    :param query_string: The part of the URL after the "?".
    :param headers: The headers received with the request.
    :param remote_addr: The address of the client sending the request.

    .. versionchanged:: 3.0
        The ``charset``, ``url_charset``, and ``encoding_errors`` attributes
        were removed.

    .. versionadded:: 2.0
    ztype[MultiDict[str, t.Any]]parameter_storage_classdict_storage_classztype[list[t.Any]]list_storage_classztype[UserAgent]user_agent_classNzlist[str] | Nonetrusted_hostsstrztuple[str, int | None] | Nonebytesr
   z
str | NoneNone)	methodschemeserver	root_pathpathquery_stringheadersremote_addrreturnc	           	      C  sH   |  | _|| _|| _|d| _d|d | _|| _|| _	|| _
d S )N/)upperr.   r/   r0   rstripr1   lstripr2   r3   r4   r5   )	selfr.   r/   r0   r1   r2   r3   r4   r5    r<   P/var/www/ai-form-bot/venv/lib/python3.9/site-packages/werkzeug/sansio/request.py__init__v   s    
zRequest.__init__)r6   c              
   C  s\   z
| j }W n0 ty: } zd| d}W Y d }~n
d }~0 0 dt| j d|d| j dS )Nz(invalid URL: )< z [z]>)url	Exceptiontype__name__r.   )r;   rB   er<   r<   r=   __repr__   s
    
"zRequest.__repr__zMultiDict[str, str]c                 C  s   |  t| j dddS )a  The parsed URL parameters (the part in the URL after the question
        mark).

        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.

        .. versionchanged:: 2.3
            Invalid bytes remain percent encoded.
        Tzwerkzeug.url_quote)keep_blank_valueserrors)r&   r   r3   decoder;   r<   r<   r=   args   s    zRequest.argsz	list[str]c                 C  s>   d| j v r| t| j d S | jdur6| | jgS |  S )z}If a forwarded header exists this is a list of all ip addresses
        from the client ip to the last proxy server.
        zX-Forwarded-ForN)r4   r(   r   r5   rK   r<   r<   r=   access_route   s    

zRequest.access_routec                 C  s   | j  d| j  S )z+Requested path, including the query string.?)r2   r3   rJ   rK   r<   r<   r=   	full_path   s    zRequest.full_pathboolc                 C  s
   | j dv S )zX``True`` if the request was made with a secure protocol
        (HTTPS or WSS).
        >   httpswss)r/   rK   r<   r<   r=   	is_secure   s    zRequest.is_securec                 C  s   t | j| j| j| j| jS )zVThe full request URL with the scheme, host, root path, path,
        and query string.)r#   r/   hostr1   r2   r3   rK   r<   r<   r=   rB      s    zRequest.urlc                 C  s   t | j| j| j| jS )z.Like :attr:`url` but without the query string.)r#   r/   rT   r1   r2   rK   r<   r<   r=   base_url   s    zRequest.base_urlc                 C  s   t | j| j| jS )zuThe request URL scheme, host, and root path. This is the root
        that the application is accessed from.
        )r#   r/   rT   r1   rK   r<   r<   r=   root_url   s    zRequest.root_urlc                 C  s   t | j| jS )z%The request URL scheme and host only.)r#   r/   rT   rK   r<   r<   r=   host_url   s    zRequest.host_urlc                 C  s   t | j| jd| j| jS )zThe host name the request was made to, including the port if
        it's non-standard. Validated with :attr:`trusted_hosts`.
        rT   )r$   r/   r4   getr0   r*   rK   r<   r<   r=   rT      s    zRequest.hostzImmutableMultiDict[str, str]c                 C  s    d | jd}t|| jdS )zVA :class:`dict` with the contents of all cookies transmitted with
        the request.;Cookie)cls)joinr4   getlistr!   r'   )r;   Zwsgi_combined_cookier<   r<   r=   cookies   s    zRequest.cookiesContent-TypezThe Content-Type entity-header field indicates the media
        type of the entity-body sent to the recipient or, in the case of
        the HEAD method, the media type that would have been sent had
        the request been a GET.T)doc	read_onlyz
int | Nonec                 C  s   t | jd| jddS )zThe Content-Length entity-header field indicates the size of the
        entity-body in bytes or, in the case of the HEAD method, the size of
        the entity-body that would have been sent had the request been a
        GET.
        zContent-LengthzTransfer-Encoding)Zhttp_content_lengthZhttp_transfer_encoding)r"   r4   rX   rK   r<   r<   r=   content_length  s    

zRequest.content_lengthzContent-Encodinga  The Content-Encoding entity-header field is used as a
        modifier to the media-type. When present, its value indicates
        what additional content codings have been applied to the
        entity-body, and thus what decoding mechanisms must be applied
        in order to obtain the media-type referenced by the Content-Type
        header field.

        .. versionadded:: 0.9zContent-MD5a  The Content-MD5 entity-header field, as defined in
        RFC 1864, is an MD5 digest of the entity-body for the purpose of
        providing an end-to-end message integrity check (MIC) of the
        entity-body. (Note: a MIC is good for detecting accidental
        modification of the entity-body in transit, but is not proof
        against malicious attacks.)

        .. versionadded:: 0.9ZRefererzThe Referer[sic] request-header field allows the client
        to specify, for the server's benefit, the address (URI) of the
        resource from which the Request-URI was obtained (the
        "referrer", although the header field is misspelled).DatezThe Date general-header field represents the date and
        time at which the message was originated, having the same
        semantics as orig-date in RFC 822.

        .. versionchanged:: 2.0
            The datetime object is timezone-aware.
        zMax-ForwardszThe Max-Forwards request-header field provides a
        mechanism with the TRACE and OPTIONS methods to limit the number
        of proxies or gateways that can forward the request to the next
        inbound server.c                 C  s"   t | dst| jdd| _d S )N_parsed_content_typer_    )hasattrr   r4   rX   rd   rK   r<   r<   r=   _parse_content_typeH  s    
zRequest._parse_content_typec                 C  s   |    | jd  S )zLike :attr:`content_type`, but without parameters (eg, without
        charset, type etc.) and always lowercase.  For example if the content
        type is ``text/HTML; charset=utf-8`` the mimetype would be
        ``'text/html'``.
        r   )rg   rd   lowerrK   r<   r<   r=   mimetypeN  s    zRequest.mimetypezdict[str, str]c                 C  s   |    | jd S )zThe mimetype parameters as dict.  For example if the content
        type is ``text/html; charset=utf-8`` the params would be
        ``{'charset': 'utf-8'}``.
        r    )rg   rd   rK   r<   r<   r=   mimetype_paramsX  s    zRequest.mimetype_paramsr   c                 C  s   t | jddS )aj  The Pragma general-header field is used to include
        implementation-specific directives that might apply to any recipient
        along the request/response chain.  All pragma directives specify
        optional behavior from the viewpoint of the protocol; however, some
        systems MAY require that behavior be consistent with the directives.
        ZPragmare   )r   r4   rX   rK   r<   r<   r=   pragmaa  s    zRequest.pragmar   c                 C  s   t | jdtS )zoList of mimetypes this client supports as
        :class:`~werkzeug.datastructures.MIMEAccept` object.
        r   )r   r4   rX   r   rK   r<   r<   r=   accept_mimetypesm  s    zRequest.accept_mimetypesr   c                 C  s   t | jdtS )zqList of charsets this client supports as
        :class:`~werkzeug.datastructures.CharsetAccept` object.
        zAccept-Charset)r   r4   rX   r   rK   r<   r<   r=   accept_charsetst  s    zRequest.accept_charsetsr   c                 C  s   t | jdS )zList of encodings this client accepts.  Encodings in a HTTP term
        are compression encodings such as gzip.  For charsets have a look at
        :attr:`accept_charset`.
        zAccept-Encoding)r   r4   rX   rK   r<   r<   r=   accept_encodings{  s    zRequest.accept_encodingsr   c                 C  s   t | jdtS )a   List of languages this client accepts as
        :class:`~werkzeug.datastructures.LanguageAccept` object.

        .. versionchanged 0.5
           In previous versions this was a regular
           :class:`~werkzeug.datastructures.Accept` object.
        zAccept-Language)r   r4   rX   r   rK   r<   r<   r=   accept_languages  s    	zRequest.accept_languagesr   c                 C  s   | j d}t|dtS )zwA :class:`~werkzeug.datastructures.RequestCacheControl` object
        for the incoming cache control headers.
        zCache-ControlN)r4   rX   r   r   )r;   cache_controlr<   r<   r=   rp     s    zRequest.cache_controlr	   c                 C  s   t | jdS )z~An object containing all the etags in the `If-Match` header.

        :rtype: :class:`~werkzeug.datastructures.ETags`
        zIf-Matchr   r4   rX   rK   r<   r<   r=   if_match  s    zRequest.if_matchc                 C  s   t | jdS )zAn object containing all the etags in the `If-None-Match` header.

        :rtype: :class:`~werkzeug.datastructures.ETags`
        zIf-None-Matchrq   rK   r<   r<   r=   if_none_match  s    zRequest.if_none_matchzdatetime | Nonec                 C  s   t | jdS )zThe parsed `If-Modified-Since` header as a datetime object.

        .. versionchanged:: 2.0
            The datetime object is timezone-aware.
        zIf-Modified-Sincer   r4   rX   rK   r<   r<   r=   if_modified_since  s    zRequest.if_modified_sincec                 C  s   t | jdS )zThe parsed `If-Unmodified-Since` header as a datetime object.

        .. versionchanged:: 2.0
            The datetime object is timezone-aware.
        zIf-Unmodified-Sincert   rK   r<   r<   r=   if_unmodified_since  s    zRequest.if_unmodified_sincer   c                 C  s   t | jdS )zThe parsed ``If-Range`` header.

        .. versionchanged:: 2.0
            ``IfRange.date`` is timezone-aware.

        .. versionadded:: 0.7
        zIf-Range)r   r4   rX   rK   r<   r<   r=   if_range  s    	zRequest.if_rangezRange | Nonec                 C  s   t | jdS )z{The parsed `Range` header.

        .. versionadded:: 0.7

        :rtype: :class:`~werkzeug.datastructures.Range`
        r   )r   r4   rX   rK   r<   r<   r=   range  s    zRequest.ranger   c                 C  s   |  | jddS )a  The user agent. Use ``user_agent.string`` to get the header
        value. Set :attr:`user_agent_class` to a subclass of
        :class:`~werkzeug.user_agent.UserAgent` to provide parsing for
        the other properties or other extended data.

        .. versionchanged:: 2.1
            The built-in parser was removed. Set ``user_agent_class`` to a ``UserAgent``
            subclass to parse data from the string.
        z
User-Agentre   )r)   r4   rX   rK   r<   r<   r=   
user_agent  s    zRequest.user_agentzAuthorization | Nonec                 C  s   t | jdS )aG  The ``Authorization`` header parsed into an :class:`.Authorization` object.
        ``None`` if the header is not present.

        .. versionchanged:: 2.3
            :class:`Authorization` is no longer a ``dict``. The ``token`` attribute
            was added for auth schemes that use a token instead of parameters.
        r   )r   Zfrom_headerr4   rX   rK   r<   r<   r=   authorization  s    	zRequest.authorizationZOriginzThe host that the request originated from. Set :attr:`~CORSResponseMixin.access_control_allow_origin` on the response to indicate which origins are allowed.zAccess-Control-Request-HeaderszSent with a preflight request to indicate which headers will be sent with the cross origin request. Set :attr:`~CORSResponseMixin.access_control_allow_headers` on the response to indicate which headers are allowed.)Z	load_funcr`   ra   zAccess-Control-Request-MethodzSent with a preflight request to indicate which method will be used for the cross origin request. Set :attr:`~CORSResponseMixin.access_control_allow_methods` on the response to indicate which methods are allowed.c                 C  s"   | j }|dkp |do |dS )zCheck if the mimetype indicates JSON data, either
        :mimetype:`application/json` or :mimetype:`application/*+json`.
        zapplication/jsonzapplication/z+json)ri   
startswithendswith)r;   mtr<   r<   r=   is_json  s
    
zRequest.is_json)<rE   
__module____qualname____doc__r   r&   __annotations__r'   r   r(   r   r)   r*   r>   rG   r   rL   rM   rO   propertyrS   rB   rU   rV   rW   rT   r^   r   r+   content_typerb   content_encodingZcontent_md5Zreferrerr   dateintZmax_forwardsrg   ri   rj   rk   rl   rm   rn   ro   rp   rr   rs   ru   rv   rw   rx   ry   rz   originr   Zaccess_control_request_headersZaccess_control_request_methodr~   r<   r<   r<   r=   r%   '   s   
%
!
		

r%   )*
__future__r   typingtr   urllib.parser   Zdatastructuresr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   httpr   r   r   r   r   r   r   r   r   ry   r   utilsr   r   r!   r"   r#   r$   r%   r<   r<   r<   r=   <module>   sD   