U '7`Vg @sfddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddlm Z ddlmZmZmZmZmZmZmZmZmZmZddlmZddlZddlmZmZmZm Z ddl!m"Z"d d l#m$Z$d d l%m&Z&d d l'm(Z(m)Z)m*Z*m+Z+m,Z,d d l-m.Z.d dl/m0Z0d dl1m2Z2m3Z3d dl4m5Z5m6Z6d dl7m8Z8m9Z9m:Z:m;Z;mZ>d dl?m@Z@dZAerd dlBmCZCd dlDmEZEd dlFmGZGejHddddGdddZIejJejKdZLdeLdZMdNd Od!d"d#ePeQd$d%DZRd&ZSd'jNeReSd(ZTd)jNeMeTd*ZUeVd+ZWeVeUZXGd,d-d-eeYefe*ZZGd.d/d/eZZ[dS)0N) parsedate) SimpleCookie)MappingProxyType) TYPE_CHECKINGAnyDictIteratorMappingMutableMappingOptionalTupleUnioncast) parse_qsl) CIMultiDictCIMultiDictProxy MultiDictMultiDictProxy)URL)hdrs)AbstractStreamWriter)DEBUG ChainMapProxy HeadersMixinreifysentinel)RawRequestMessage) HttpVersion)BodyPartReaderMultipartReader)EmptyStreamReader StreamReader)DEFAULT_JSON_DECODER JSONDecoder LooseHeaders RawHeadersStrOrURL)HTTPRequestEntityTooLarge)StreamResponse) BaseRequest FileFieldRequest) Application)RequestHandler)UrlMappingMatchInfoT)Z auto_attribsfrozenslotsc@s8eZdZUeed<eed<ejed<eed<ded<dS)r+namefilenamefile content_typeCIMultiDictProxy[str]headersN)__name__ __module__ __qualname__str__annotations__ioBufferedReaderr?r?F/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/web_request.pyr+9s  r+z!#$%&'*+.^_`|~-[z]+z[{}]ccs|]}t|VqdSN)chr).0cr?r?r@ HsrG) !#z \\[\t !-~]z"(?:{quoted_pair}|{qdtext})*")ZqdtextZ quoted_pairz0({token})=({token}|{quoted_string})(:\d{{1,4}})?)tokenZ quoted_stringz \\([\t !-~])c@sleZdZejejejejejhZ e j e ddddddddd d d d d ddddgBZ dddddde ededejeeeeefeeeeeedd ddZeeeeeedeeeeeeddddZedddd Zeddd!d"Zeeejdd#d$Z eedd%d&Z!e"e dd'd(Z#e"e$dd)d*Z%e"ejdd+d,Z&eed-d.d/Z'eedd0d1d2Z(edd-d3d4Z)edd5d6Z*e+edd7d8Z,e"e-dd9d:Z.e"e/e0eefd;fddd?Z2e"edd@dAZ3e"e4ddBdCZ5e"eddDdEZ6e"eeddFdGZ7e"e$ddHdIZ8e"eddJdKZ9e"eddLdMZ:e"eddNdOZ;e"dPddQdRZe"e?ddXdYZ@eAeeeeBjBdZd[d\ZCe"eeBjBdd]d^ZDe"eeBjBdd_d`ZEe"eeBjBddadbZFe"e-ddcddZGe"e0eefddedfZHe"eIddgdhZJe"eddidjZKee-ddkdlZLee-ddmdnZMe"e-ddodpZNdddqdrZOePddsdtZQeddudvZReSdweTedxdydzZUeVdd{d|ZWd}dd~dZXdeeedddZYedddZZe[e-dddZ\e-dddZ]e^ddddZ_e`ddddZadS)r*_message _protocol_payload_writer_payload_headers_method_version_rel_url_post _read_bytes_state_cache_task_client_max_size_loop_transport_sslcontext_transport_peernameiN)client_max_sizestateschemehostremoter.zasyncio.Task[None]) messagepayloadprotocolpayload_writertaskloopr_r`rarbrcreturnc Cs|dkr i}||_||_||_||_|j|_|j|_|j|_ |j |_ d|_ d|_ ||_i|_||_||_||_|jj} | dk st| d|_| d|_| dk r| |jd<| dk r| |jd<| dk r| |jd<dS)NZ sslcontextZpeernamerarbrc)rNrOrPrQr7rRmethodrSversionrTurlrUrVrWrXrYrZr[r\ transportAssertionErrorget_extra_infor]r^) selfrdrerfrgrhrir_r`rarbrcrnr?r?r@__init__s8     zBaseRequest.__init__rkrel_urlr7rarbrcrkrtr7rarbrcrjc Cs|jrtdi}|tk r"||d<|tk rFt|}||d<t||d<|tk rxtt||d<tdd|D|d<|j j f|} i} |tk r|| d <|tk r|| d <|tk r|| d <|j | |j |j |j|j|jf|j|jd | S) aClone itself with replacement some attributes. Creates and returns a new instance of Request object. If no parameters are given, an exact copy is returned. If a parameter is not passed, it will reuse the one from the current request object. z.Cannot clone request after reading its contentrkrmpathr7css&|]\}}|d|dfVqdS)utf-8N)encode)rEkvr?r?r@rGsz$BaseRequest.clone.. raw_headersrarbrc)r_r`)rW RuntimeErrorrrr;rrtupleitemsrN_replace __class__rQrOrPrZr\r[rXcopy) rqrkrtr7rarbrcZdctZnew_urlrdkwargsr?r?r@clonesF   zBaseRequest.clonerjcCs|jSrC)rZrqr?r?r@rhszBaseRequest.taskcCs|jSrC)rOrr?r?r@rfszBaseRequest.protocolcCs|jdkrdS|jjSrC)rOrnrr?r?r@rns zBaseRequest.transportcCs|jSrC)rPrr?r?r@writerszBaseRequest.writercCstjdtdd|jS)NzRequest.message is deprecated stacklevel)warningswarnDeprecationWarningrNrr?r?r@rdszBaseRequest.messagecCs|jSrC)rUrr?r?r@rtszBaseRequest.rel_urlcCstjdtdd|jS)Nz#request.loop property is deprecatedr)rrrr\rr?r?r@ris zBaseRequest.loop)keyrjcCs |j|SrCrXrqrr?r?r@ __getitem__szBaseRequest.__getitem__)rvaluerjcCs||j|<dSrCr)rqrrr?r?r@ __setitem__szBaseRequest.__setitem__cCs |j|=dSrCrrr?r?r@ __delitem__szBaseRequest.__delitem__cCs t|jSrC)lenrXrr?r?r@__len__szBaseRequest.__len__cCs t|jSrC)iterrXrr?r?r@__iter__szBaseRequest.__iter__cCs |jdkS)z5A bool indicating if the request is handled with SSL.https)rarr?r?r@secure szBaseRequest.secure.c CsXg}|jjtjdD]6}t|}d}d}i}|t|d|krT|krnqt ||}|dk r|r~| d|}n\| \}} } | ddkrt d| dd } | r| | 7} | ||<|t|d7}d }q@||dkr d}i}|t||d7}q@||d kr(d}|d7}q@||d kr@|d7}q@| d|}q@qt|S) aA tuple containing all parsed Forwarded header(s). Makes an effort to parse Forwarded headers as specified by RFC 7239: - It adds one (immutable) dictionary per Forwarded 'field-value', ie per proxy. The element corresponds to the data in the Forwarded field-value added by the first proxy encountered by the client. Each subsequent item corresponds to those added by later proxies. - It checks that every value has valid syntax in general as specified in section 4: either a 'token' or a 'quoted-string'. - It un-escapes found escape sequences. - It does NOT validate 'by' and 'for' contents as specified in section 6. - It does NOT validate 'host' contents (Host ABNF). - It does NOT validate 'proto' contents for valid URI scheme names. Returns a tuple containing one or more immutable dicts r?rFN,"z\1rT;z )rNr7ZgetallrZ FORWARDEDrappendtypesr_FORWARDED_PAIR_REmatchfindgroups_QUOTED_PAIR_REPLACE_REsublowergroupr}) rqZelemsZ field_valueZlengthposZneed_separatorelemrr2rZportr?r?r@ forwarded%s@      zBaseRequest.forwardedcCs|jr dSdSdS)aA string representing the scheme of the request. Hostname is resolved in this order: - overridden value by .clone(scheme=new_scheme) call. - type of connection to peer: HTTPS if socket is SSL, HTTP otherwise. 'http' or 'https'. rZhttpN)r]rr?r?r@rabs zBaseRequest.schemecCs|jS)zyRead only property for getting HTTP method. The value is upper-cased str like 'GET', 'POST', 'PUT' etc. )rSrr?r?r@rkrszBaseRequest.methodcCs|jS)zxRead only property for getting HTTP version of request. Returns aiohttp.protocol.HttpVersion instance. )rTrr?r?r@rlzszBaseRequest.versioncCs(|jjtj}|dk r|StSdS)zHostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value N)rNr7getrZHOSTsocketZgetfqdn)rqrbr?r?r@rbs zBaseRequest.hostcCs$t|jttfr|jdS|jSdS)zRemote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket rN) isinstancer^listr}rr?r?r@rcs  zBaseRequest.remotecCstj|j|jd}||jS)N)rarb)rZbuildrarbjoinrU)rqrmr?r?r@rmszBaseRequest.urlcCs|jjS)z_The URL including *PATH INFO* without the host or scheme. E.g., ``/app/blog`` )rUrvrr?r?r@rvszBaseRequest.pathcCs t|jS)zXThe URL including PATH_INFO and the query string. E.g, /app/blog?id=10 )r;rUrr?r?r@path_qsszBaseRequest.path_qscCs|jjS)zThe URL including raw *PATH INFO* without the host or scheme. Warning, the path is unquoted and may contains non valid URL characters E.g., ``/my%2Fpath%7Cwith%21some%25strange%24characters`` )rNrvrr?r?r@raw_pathszBaseRequest.raw_pathzMultiDictProxy[str]cCs|jjS)z7A multidict with all the variables in the query string.)rUqueryrr?r?r@rszBaseRequest.querycCs|jjS)z:The query string in the URL. E.g., id=10 )rU query_stringrr?r?r@rszBaseRequest.query_stringr6cCs|jS)z4A case-insensitive multidict proxy with all headers.)rRrr?r?r@r7szBaseRequest.headerscCs|jjS)z$A sequence of pairs for all headers.)rNr{rr?r?r@r{szBaseRequest.raw_headers) _date_strrjcCs8|dk r4t|}|dk r4tj|dddtjjiSdS)z/Process a date string, return a datetime objectNZtzinfo)rdatetimetimezoneZutc)rZ timetupler?r?r@ _http_dates zBaseRequest._http_datecCs||jtjS)zyThe value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object. )rr7rrZIF_MODIFIED_SINCErr?r?r@if_modified_sinceszBaseRequest.if_modified_sincecCs||jtjS)z{The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object. )rr7rrZIF_UNMODIFIED_SINCErr?r?r@if_unmodified_sinceszBaseRequest.if_unmodified_sincecCs||jtjS)zpThe value of If-Range HTTP header, or None. This header is represented as a `datetime` object. )rr7rrZIF_RANGErr?r?r@if_rangeszBaseRequest.if_rangecCs |jj S)zIs keepalive enabled by client?)rNZ should_closerr?r?r@ keep_aliveszBaseRequest.keep_alivecCs.|jtjd}t|}tdd|DS)zMReturn request cookies. A read-only dictionary-like object. rBcSsi|]\}}||jqSr?)r)rErvalr?r?r@ sz'BaseRequest.cookies..)r7rrZCOOKIErrr~)rqrawZparsedr?r?r@cookiesszBaseRequest.cookiescCs|jtj}d\}}|dk rzd}t||d\}}Wntk rVtdYnX|rdt|nd}|rtt|nd}|dkr|dk r| }d}|dk r|dk r|d7}||krtd||krdkrnntdt ||dS) zMThe content of Range HTTP header. Return a slice instance. )NNNz^bytes=(\d*)-(\d*)$rzrange not in acceptable formatrzstart cannot be after endz"No start or end of range specified) rRrrRANGErefindall IndexError ValueErrorintslice)rqrngstartendpatternr?r?r@ http_ranges(zBaseRequest.http_rangecCs|jS)zReturn raw payload stream.)rQrr?r?r@content)szBaseRequest.contentcCstjdtdd|j S)@Return True if request's HTTP BODY can be read, False otherwise.z$Deprecated, use .can_read_body #2005rr)rrrrQat_eofrr?r?r@has_body.s zBaseRequest.has_bodycCs |j S)r)rQrrr?r?r@ can_read_body6szBaseRequest.can_read_bodycCst|jtk S)z6Return True if request has HTTP BODY, False otherwise.)typerQr!rr?r?r@ body_exists;szBaseRequest.body_existscs |js|jIdHqdS)zKRelease request. Eat unread part of HTTP BODY if present. N)rQrreadanyrr?r?r@release@s zBaseRequest.releasecsh|jdkrbt}|jIdH}|||jrPt|}||jkrPt|j|d|sqXqt||_|jS)z_Read request body if present. Returns bytes object with full request content. Nmax_sizeZ actual_size) rW bytearrayrQrextendr[rr(bytes)rqbodychunkZ body_sizer?r?r@readHs    zBaseRequest.readcs"|IdH}|jpd}||S)z1Return BODY as text using encoding from .charset.Nrw)rcharsetdecode)rqZ bytes_bodyencodingr?r?r@text]s zBaseRequest.text)loads)rrjcs|IdH}||S)zReturn BODY as JSON.N)r)rqrrr?r?r@jsoncszBaseRequest.jsoncst|j|jS)z3Return async iterator to process BODY as multipart.)r rRrQrr?r?r@ multiparthszBaseRequest.multipartz,MultiDictProxy[Union[str, bytes, FileField]]csv|jdk r|jS|j|jkr.tt|_|jS|j}|dkrNtt|_|jSt}|dkr(|IdH}|j}|IdH}|dk rfd}|j t j }t |tr|jdk st|jrt}|jddIdH} | r:|| } || |t| 7}d|kr|kr&nn t||d|jddIdH} q|d|dkrRd}t|j|jttj|||j } ||j| n|jd d IdH} |dks| d r|j!d d } ||j| | n||j| |t| 7}d|kr|krnn t||dnt"d|IdH}qn>|IdH} | rf|j#pFd } |$t%| &| d | dt||_|jS)zReturn POST parameters.N)rBz!application/x-www-form-urlencodedmultipart/form-datarri)sizerzapplication/octet-streamT)rztext/rw)defaultz8To decode nested multipart you need to use custom reader)Zkeep_blank_valuesr)'rVrS POST_METHODSrrr5rr[nextr7rrZ CONTENT_TYPErrr2ror3tempfileZ TemporaryFileZ read_chunkrwriterr(seekr+rr=r>addr startswithZ get_charsetrrrrrstrip)rqr5outrrZfieldrZfield_ctZtmprZffrrdatar?r?r@postls                  zBaseRequest.post)r2rrjcCs0|j}|dkr|S|j}|dkr$|S|||S)z"Extra info from protocol transportN)rOrnrp)rqr2rrfrnr?r?r@rpszBaseRequest.get_extra_infocCs(|jddd}d|jj|j|S)Nasciibackslashreplacez <{} {} {} >)rvrxrformatrr8rS)rqZascii_encodable_pathr?r?r@__repr__szBaseRequest.__repr__)otherrjcCst|t|kSrC)id)rqrr?r?r@__eq__szBaseRequest.__eq__cCsdS)NTr?rr?r?r@__bool__szBaseRequest.__bool__responserjcsdSrCr?)rqrr?r?r@ _prepare_hookszBaseRequest._prepare_hook)excrjcCs|j|dSrC)rQZ set_exception)rqrr?r?r@_cancelszBaseRequest._cancel)N)br8r9r:rZ METH_PATCHZ METH_POSTZMETH_PUTZ METH_TRACEZ METH_DELETErrATTRS frozensetrr"rasyncioZAbstractEventLooprr rr;rrrrr'r%rpropertyrhrfZ Transportrnrrrdrrtrirrrrrrboolrr r rrarkrrlrbrcrmrvrrrrr7r&r{ staticmethodrrrrrrrrrrrrrrrrrr#r$rr rrrprobjectrrr)r BaseExceptionrr?r?r?r@r*as 4 9 <  #_ r*c seZdZejedgBZeeddfdd ZerHe eddfdd Z e e e e e e d e e e e e e dd fd d Zed dddZeddddZeedddZeddddZZS)r, _match_infoN)argsrrjcstj||d|_dSrC)superrrr )rqr rrr?r@rrszRequest.__init__)r2rrjcs8||jkr&tjd|jj|tddt||dS)Nz-Setting custom {}.{} attribute is discouragedrr) rrrrrr8rr  __setattr__)rqr2rr r?r@r s zRequest.__setattr__rsruc s.tj||||||d}tt|}|j|_|S)Nrs)r rrr,r ) rqrkrtr7rarbrcZretZnew_retr r?r@rs  z Request.cloner/rcCs|j}|dk st|S)zResult of route resolving.N)r rorq match_infor?r?r@rs zRequest.match_infor-cCs|j}|dk st|jS)zApplication instance.N)r roZ current_apprr?r?r@app"s z Request.appcCsH|j}|dk st|j}|j}||}tt|d|d}t|S)Nr)r roZappsrindexrreversedr)rqrZlstridxZsublistr?r?r@ config_dict)s  zRequest.config_dictrcs6|j}|dkrdS|jD]}|j||IdHqdSrC)r Z_appsZon_response_preparesend)rqrrrr?r?r@r3s  zRequest._prepare_hook)r8r9r:r*rrrrrrr;r rr'r%rrrrrrrr)r __classcell__r?r?r r@r,s4   r,)\rrr=rrstringrrrZ email.utilsrZ http.cookiesrrtypingrrrrr r r r r rZ urllib.parserattrZ multidictrrrrZyarlrrBrabcrZhelpersrrrrrZ http_parserrZ http_writerrrrr Zstreamsr!r"Ztypedefsr#r$r%r&r'Zweb_exceptionsr(Z web_responser)__all__Zweb_appr-Z web_protocolr.Zweb_urldispatcherr/sr+ZdigitsZ ascii_lettersZ_TCHARZ_TOKENrrr}rangeZ_QDTEXTZ _QUOTED_PAIRZ_QUOTED_STRINGZ_FORWARDED_PAIRcompilerrr;r*r,r?r?r?r@sp   0