U aO@sddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#dd l$m%Z&dd!l'm(Z(dd"l'm)Z)d#d$l'm*Z*d#d%l'm+Z+Gd&d'd'Z,dS)(N)datetime)_to_str)Accept) Authorization) CharsetAccept)ETags)Headers) HeaderSet)IfRange) ImmutableList)ImmutableMultiDict)LanguageAccept) MIMEAccept) MultiDict)Range)RequestCacheControl)parse_accept_header)parse_authorization_header)parse_cache_control_header) parse_cookie) parse_date) parse_etags)parse_if_range_header)parse_list_header)parse_options_header)parse_range_header)parse_set_header) url_decode) UserAgent) _UserAgent)cached_property)header_property)get_current_url)get_hostc @seZdZUdZdZdZeZej e e d<eZ ej e e d<e Zej eje d<eZdZejejee d<eeejejeejefeeeeejedd d d Zed d dZeed ddZedd ddZeejed ddZeed ddZ ee!d ddZ"eed ddZ#eed ddZ$eed ddZ%eed d d!Z&eed d"d#Z'ed$d d%d&Z(e)ed'd(d)d*Z*eejed d+d,Z+e)ed-d.d)d*Z,e)ed/d0d)d*Z-e)ed1d2d)d*Z.e)d3de/d4d)d*Z0e)d5ded6d)d*Z1dd d7d8Z2eed d9d:Z3eej4eefd d;d<Z5ee6d d=d>Z7ee8d d?d@Z9ee:d dAdBZ;eed dEdFZ?ee@d dGdHZAeeBd dIdJZCeeBd dKdLZDeejeEd dMdNZFeejeEd dOdPZGeeHd dQdRZIeejeJd dSdTZKeeLd dUdVZMeejeNd dWdXZOe)edYdZd)d*ZPe)d[eQd\d)d]ZRe)ed^d_d)d*ZSee!d d`daZTdS)bRequesta8Represents 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. .. versionadded:: 2.0 zutf-8replaceparameter_storage_classdict_storage_classlist_storage_classN trusted_hosts) methodschemeserver root_pathpath query_stringheaders remote_addrreturnc CsH||_||_||_|d|_d|d|_||_||_ ||_ dS)N/) upperr,r-r.rstripr/lstripr0r1r2r3) selfr,r-r.r/r0r1r2r3r:XC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-1tps7o9u\werkzeug\sansio\request.py__init__xs  zRequest.__init__)r4c CsZz |j}Wn.tk r8}zd|d}W5d}~XYnXdt|jd|d|jdS)Nz(invalid URL: )< z [z]>)url Exceptiontype__name__r,)r9r@er:r:r;__repr__s  zRequest.__repr__cCs|jS)zThe charset that is assumed for URLs. Defaults to the value of :attr:`charset`. .. versionadded:: 0.6 )charsetr9r:r:r; url_charsetszRequest.url_charsetzMultiDict[str, str]cCst|j|j|j|jdS)aThe 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. )errorscls)rr1rHencoding_errorsr(rGr:r:r;argss z Request.argscCs>d|jkr|t|jdS|jdk r6||jgS|S)z}If a forwarded header exists this is a list of all ip addresses from the client ip to the last proxy server. zX-Forwarded-ForN)r2r*rr3rGr:r:r; access_routes   zRequest.access_routecCs|jdt|j|jS)z+Requested path, including the query string.?)r0rr1rHrGr:r:r; full_pathszRequest.full_pathcCs |jdkS)zX``True`` if the request was made with a secure protocol (HTTPS or WSS). >httpswss)r-rGr:r:r; is_secureszRequest.is_securecCst|j|j|j|j|jS)zVThe full request URL with the scheme, host, root path, path, and query string.)r$r-hostr/r0r1rGr:r:r;r@sz Request.urlcCst|j|j|j|jS)z.Like :attr:`url` but without the query string.)r$r-rSr/r0rGr:r:r;base_urlszRequest.base_urlcCst|j|j|jS)zuThe request URL scheme, host, and root path. This is the root that the application is accessed from. )r$r-rSr/rGr:r:r;root_urlszRequest.root_urlcCst|j|jS)z%The request URL scheme and host only.)r$r-rSrGr:r:r;host_urlszRequest.host_urlcCst|j|jd|j|jS)zThe host name the request was made to, including the port if it's non-standard. Validated with :attr:`trusted_hosts`. rS)r%r-r2getr.r+rGr:r:r;rSs  z Request.hostzImmutableMultiDict[str, str]cCs(d|jd}t||j|j|jdS)zVA :class:`dict` with the contents of all cookies transmitted with the request.;Cookie)rJ)joinr2getlistrrFrKr))r9Zwsgi_combined_cookier:r:r;cookiesszRequest.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_onlyc CsX|jdddkrdS|jd}|dk rTztdt|WSttfk rRYnXdS)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. zTransfer-EncodingchunkedNzContent-Lengthr)r2rWmaxint ValueError TypeError)r9content_lengthr:r:r;rfs zRequest.content_lengthzContent-EncodingaThe 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-MD5aThe 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.9ZRefererzThe 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.cCs"t|dst|jdd|_dS)N_parsed_content_typer]r`)hasattrrr2rWrhrGr:r:r;_parse_content_typeYs  zRequest._parse_content_typecCs||jdS)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)rjrhlowerrGr:r:r;mimetype_szRequest.mimetypecCs||jdS)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#)rjrhrGr:r:r;mimetype_paramsiszRequest.mimetype_paramscCst|jddS)ajThe 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. ZPragmar`)rr2rWrGr:r:r;pragmarszRequest.pragmacCst|jdtS)zoList of mimetypes this client supports as :class:`~werkzeug.datastructures.MIMEAccept` object. r)rr2rWrrGr:r:r;accept_mimetypes~szRequest.accept_mimetypescCst|jdtS)zqList of charsets this client supports as :class:`~werkzeug.datastructures.CharsetAccept` object. zAccept-Charset)rr2rWrrGr:r:r;accept_charsetsszRequest.accept_charsetscCst|jdS)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`. zAccept-Encoding)rr2rWrGr:r:r;accept_encodingsszRequest.accept_encodingscCst|jdtS)aList 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. zAccept-Language)rr2rWrrGr:r:r;accept_languagess zRequest.accept_languagescCs|jd}t|dtS)zwA :class:`~werkzeug.datastructures.RequestCacheControl` object for the incoming cache control headers. z Cache-ControlN)r2rWrr)r9 cache_controlr:r:r;rss zRequest.cache_controlcCst|jdS)z~An object containing all the etags in the `If-Match` header. :rtype: :class:`~werkzeug.datastructures.ETags` zIf-Matchrr2rWrGr:r:r;if_matchszRequest.if_matchcCst|jdS)zAn object containing all the etags in the `If-None-Match` header. :rtype: :class:`~werkzeug.datastructures.ETags` z If-None-MatchrtrGr:r:r; if_none_matchszRequest.if_none_matchcCst|jdS)zThe parsed `If-Modified-Since` header as a datetime object. .. versionchanged:: 2.0 The datetime object is timezone-aware. zIf-Modified-Sincerr2rWrGr:r:r;if_modified_sinceszRequest.if_modified_sincecCst|jdS)zThe parsed `If-Unmodified-Since` header as a datetime object. .. versionchanged:: 2.0 The datetime object is timezone-aware. zIf-Unmodified-SincerwrGr:r:r;if_unmodified_sinceszRequest.if_unmodified_sincecCst|jdS)zThe parsed ``If-Range`` header. .. versionchanged:: 2.0 ``IfRange.date`` is timezone-aware. .. versionadded:: 0.7 zIf-Range)rr2rWrGr:r:r;if_ranges zRequest.if_rangecCst|jdS)z{The parsed `Range` header. .. versionadded:: 0.7 :rtype: :class:`~werkzeug.datastructures.Range` r)rr2rWrGr:r:r;rangesz Request.rangecCs||jddS)aThe 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.0 The built in parser is deprecated and will be removed in Werkzeug 2.1. A ``UserAgent`` subclass must be set to parse data from the string. z User-Agentr`)user_agent_classr2rWrGr:r:r; user_agents zRequest.user_agentcCst|jdS)z*The `Authorization` object in parsed form.r)rr2rWrGr:r:r; authorizationszRequest.authorizationZOriginzThe host that the request originated from. Set :attr:`~CORSResponseMixin.access_control_allow_origin` on the response to indicate which origins are allowed.zAccess-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^r_zAccess-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.cCs"|j}|dkp |do |dS)zCheck if the mimetype indicates JSON data, either :mimetype:`application/json` or :mimetype:`application/*+json`. zapplication/jsonz application/z+json)rl startswithendswith)r9mtr:r:r;is_jsons  zRequest.is_json)UrC __module__ __qualname____doc__rFrKr r(tTyper__annotations__r)r r*List_DeprecatedUserAgentr|r+OptionalstrTuplercbytesr r<rEpropertyrHr!rLrMrOboolrRr@rTrUrVrSr\r" content_typerfcontent_encodingZ content_md5ZreferrerrdateZ max_forwardsrjrlDictrmr rnrrorrprrqrrrrrsrrurvrrxryr rzrr{rr}rr~originrZaccess_control_request_headersZaccess_control_request_methodrr:r:r:r;r&'s    !               r&)-typingrr _internalrZdatastructuresrrrrr r r r r rrrrrhttprrrrrrrrrrrurlsrr}rZ useragentsr rutilsr!r"r$r%r&r:r:r:r;sF