e:*SrS/rSSKrSSKrSSKr\R "S5r\R "S5r"SS\5r Sr S r S r "S S 5r "S S5r"SS5r"SS5r"SS5rSrSrSrSrSrSrSrSrg)a& Middleware to check for obedience to the WSGI specification. Some of the things this checks: * Signature of the application and start_response (including that keyword arguments are not used). * Environment checks: - Environment is a dictionary (and not a subclass). - That all the required keys are in the environment: REQUEST_METHOD, SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors, wsgi.multithread, wsgi.multiprocess, wsgi.run_once - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the environment (these headers should appear as CONTENT_LENGTH and CONTENT_TYPE). - Warns if QUERY_STRING is missing, as the cgi module acts unpredictably in that case. - That CGI-style variables (that don't contain a .) have (non-unicode) string values - That wsgi.version is a tuple - That wsgi.url_scheme is 'http' or 'https' (@@: is this too restrictive?) - Warns if the REQUEST_METHOD is not known (@@: probably too restrictive). - That SCRIPT_NAME and PATH_INFO are empty or start with / - That at least one of SCRIPT_NAME or PATH_INFO are set. - That CONTENT_LENGTH is a positive integer. - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should be '/'). - That wsgi.input has the methods read, readline, readlines, and __iter__ - That wsgi.errors has the methods flush, write, writelines * The status is a string, contains a space, starts with an integer, and that integer is in range (> 100). * That the headers is a list (not a subclass, not another kind of sequence). * That the items of the headers are tuples of strings. * That there is no 'status' header (that is used in CGI, but not in WSGI). * That the headers don't contain newlines or colons, end in _ or -, or contain characters codes below 037. * That Content-Type is given if there is content (CGI often has a default content type, but WSGI does not). * That no Content-Type is given when there is no content (@@: is this too restrictive?) * That the exc_info argument to start_response is a tuple or None. * That all calls to the writer are with strings, and no other methods on the writer are accessed. * That wsgi.input is used properly: - .read() is called with exactly one argument - That it returns a string - That readline, readlines, and __iter__ return strings - That .close() is not called - No other methods are provided * That wsgi.errors is used properly: - .write() and .writelines() is called with a string - That .close() is not called, and no other methods are provided. * The response iterator: - That it is not a string (it should be a list of a single string; a string will work, but perform horribly). - That .__next__() returns a string - That the iterator is not iterated over until start_response has been called (that can signal either a server or application error). - That .close() is called (doesn't raise exception, only prints to sys.stderr, because we only know it isn't called when the object is garbage collected). validatorNz^[a-zA-Z][a-zA-Z0-9\-_]*$z [\000-\037]c\rSrSrSrSrg) WSGIWarningyz2 Raised in response to WSGI-spec-related warnings N)__name__ __module__ __qualname____firstlineno____doc____static_attributes__r6/opt/imh/python3.13/lib/python3.13/wsgiref/validate.pyrrysrrc"U(d[U6egN)AssertionError)condargss rassert_r~s d## rcr[U5[LaU$[SRU[ U555e)Nz!{0} must be of type str (got {1}))typestrrformatrepr)valuetitles rcheck_string_typers6 U|s +225$u+F HHrc^U4SjnU$)a When applied between a WSGI server and a WSGI application, this middleware will check for WSGI compliance on a number of levels. This middleware does not modify the request or response in any way, but will raise an AssertionError if anything seems off (except for a failure to close the application iterator, which will be printed to stderr -- there's no way to raise an exception at that point). cB>^^[[U5S:HS5 [U(+S5 Uunm[U5 /mUU4Sjn[US5US'[ US5US'T"X#5n[USL=(a US:gS5 [ U5 [ UT5$) NzTwo arguments requiredNo keyword arguments allowedc`>[[U5S:H=(d [U5S:HSU<35 [U(+S5 USnUSn[U5S:XaUSnOSn[U5 [U5 [ X#5 [ U5 TR S5 [T"U65$)Nr zInvalid number of arguments: r!r)rlen check_status check_headerscheck_content_typecheck_exc_infoappend WriteWrapper)rkwstatusheadersexc_infostart_responsestart_response_starteds rstart_response_wrapper;validator..lint_app..start_response_wrappers CIN4c$i1n59; > F: ;!WF1gG4yA~7  ' " v / 8 $ " ) )$ / 56 6r wsgi.input wsgi.errorsFz>The application must return an iterator, if only an empty list)rr% check_environ InputWrapper ErrorWrappercheck_iteratorIteratorWrapper)rr,environr2iteratorr0r1 applications @@rlint_appvalidator..lint_appsD Q 89B67"&g"$ 7&!-W\-B C !-gm.D!E w?$:U): L N x x)?@@rr)r=r>s` rrrs'AR Orc8\rSrSrSrSrSrSrSrSr Sr g ) r7cXlgrinput)self wsgi_inputs r__init__InputWrapper.__init__s rc[[U5S:H5 URR"U6n[[ U5[ L5 U$Nr$)rr%rDreadrbytesrErvs rrKInputWrapper.reads:D Q JJOOT "Q5 !rc[[U5S:*5 URR"U6n[[ U5[ L5 U$rJ)rr%rDreadlinerrLrMs rrQInputWrapper.readlines<D Q JJ   &Q5 !rc[[U5S:*5 URR"U6n[[ U5[ L5 UHn[[ U5[ L5 M U$rJ)rr%rD readlinesrlistrL)rErlineslines rrTInputWrapper.readlinessWD Q $$d+U t#$D DJ%' ( rc#v# UR5=n(aUv UR5=n(aMgg7fr)rQ)rErWs r__iter__InputWrapper.__iter__s1mmo%d%Jmmo%d%%s399c[SS5 g)Nrz input.close() must not be calledrrEs rcloseInputWrapper.closes 56rrCN) rr r r rGrKrQrTrZr_r rrrr7r7s    7rr7c2\rSrSrSrSrSrSrSrSr g) r8cXlgrerrors)rE wsgi_errorss rrGErrorWrapper.__init__! rcn[[U5[L5 URR U5 gr)rrrrewriterEss rrjErrorWrapper.writes$Q3 !rc8URR5 gr)reflushr^s rroErrorWrapper.flushs rc8UHnURU5 M gr)rj)rEseqrWs r writelinesErrorWrapper.writelinessD JJt rc[SS5 g)Nrz!errors.close() must not be calledr]r^s rr_ErrorWrapper.closes 67rrdN) rr r r rGrjrorsr_r rrrr8r8s"8rr8c \rSrSrSrSrSrg)r+cXlgrwriter)rE wsgi_writers rrGWriteWrapper.__init__rhrcZ[[U5[L5 URU5 gr)rrrLr{rks r__call__WriteWrapper.__call__sQ5 ! ArrzN)rr r r rGrr rrrr+r+s "rr+c \rSrSrSrSrSrg)PartialIteratorWrappercXlgrr<)rE wsgi_iterators rrGPartialIteratorWrapper.__init__s% rc.[URS5$r)r:r<r^s rrZPartialIteratorWrapper.__iter__st}}d33rrN)rr r r rGrZr rrrrrs &4rrc2\rSrSrSrSrSrSrSrSr g) r:icJXl[U5UlSUlX lg)NF)original_iteratoriterr<closedcheck_start_response)rErrs rrGIteratorWrapper.__init__s!!.]+  $8!rcU$rrr^s rrZIteratorWrapper.__iter__ s rc[UR(+S5 [UR5n[ U5[ La[SSU<S35 UR b[UR S5 SUlU$)NzIterator read after closedFz!Iterator yielded non-bytestring ()zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrnextr<rrLr)rErNs r__next__IteratorWrapper.__next__siDKK ( *   7%  EQH I  $ $ 0 D--| ~(,D %rc~SUl[URS5(aURR5 gg)NTr_)rhasattrrr_r^s rr_IteratorWrapper.closes3 4))7 3 3  " " ( ( * 4rcUR(d[RRS5 [ URS5 g)Nz/Iterator garbage collected without being closed)rsysstderrrjrr^s r__del__IteratorWrapper.__del__ s0{{ JJ  A C = ?r)rrr<rN) rr r r rGrZrr_rr rrrr:r:s9  + ?rr:c [[U5[LS[U5<SU<S35 SHn[X;SU<35 M SHn[X;SU<SUS S<S 35 M S U;a[R"S [ 5 UR 5HBnS U;aM [[X5[LSU<S[X5<SX<S35 MD [[US5[LSUS<S35 [USS;SUS-5 [US5 [US5 USS;a![R"SUS-[ 5 [URS5(+=(d USRS5SUS-5 [URS5(+=(d USRS5SUS-5 URS 5(a![[US 5S!:S"US -5 URS5(d[SU;S#5 [URS5S:gS$5 g)%Nz&Environment is not of the right type: z (environment: r) REQUEST_METHOD SERVER_NAME SERVER_PORT wsgi.versionr4r5zwsgi.multithreadzwsgi.multiprocessz wsgi.run_oncez"Environment missing required key: )HTTP_CONTENT_TYPEHTTP_CONTENT_LENGTHz%Environment should not have the key: z (use z instead) QUERY_STRINGzQUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely.zEnvironmental variable z is not a string: z (value: rz wsgi.version should be a tuple (zwsgi.url_scheme)httphttpszwsgi.url_scheme unknown: %rr4r5r)GETHEADPOSTOPTIONSPATCHPUTDELETETRACEzUnknown REQUEST_METHOD: %r SCRIPT_NAME/z$SCRIPT_NAME doesn't start with /: %r PATH_INFOz"PATH_INFO doesn't start with /: %rCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')rrdictwarningswarnrkeysrtuple check_input check_errorsget startswithint)r;keys rr6r6'sj DMT ! =' #$! 69 ; = !<""%s12w 0 1< W$  4    ||~ #: W\"c)D&  6 7  D( )U 2181HJL G% &*; ;%0A(BBD %&'( )MM (73C+D D    M* * 6}%005.1GGI  K( ( 4{#..s3,w{/CCE{{#$$G,-.!3 (73C+D D F ;;} % % w& > ? GKK &# - "#rcPSH n[[X5SU<SU<35 M" g)N)rKrQrTrZz wsgi.input () doesn't have the attribute rr)rFattrs rrrhs%= )4 ! ">rcPSH n[[X5SU<SU<35 M" g)N)rorjrsz wsgi.errors (rr)rfrs rrrns%0 *D " #1rc$[US5nURSS5Sn[[U5S:HSU-5 [ U5n[US:SU-5 [U5S:d USS :wa[ R "S U-[5 gg) NStatusr$rr#z)Status codes must be three characters: %rdzStatus code is invalid: %r zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)rsplitrr%rrrr)r- status_code status_ints rr&r&ts vx 0F,,tQ'*K C  !3kAC[!J J# ;jHI 6{Q&)s*  B ! #+rc [[U5[LSU<S[U5<35 UGHWn[[U5[LSU<S[U5<35 [[ U5S:H5 Uup#[ US5n[ US5n[UR 5S:gS U-5 [S U;=(a S U;S U-5 [[RU5S U-5 [URS5(+=(a URS5(+SU-5 [RU5(dGM [SSU<S[RU5RS5<S35 GMZ g)Nz Headers (z) must be of type list: zIndividual headers (z) must be of type tuple: r Header namez Header valuer-zyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r). :z,Header names may not contain ':' or '\n': %rzBad header name: %r-_z#Names may not end in '-' or '_': %rrzBad header value: z (bad char: r) rrrUrr%rlower header_researchendswithbad_header_value_regroup)r.itemnamers rr'r'sN DMT ! DM #$T e#T$Z ! " D Q  }5!%8 ( " # $ D 4S_ ;d B D   &(=(DEDMM#&&At}}S/A+A 1D 8 :  % %e , , A)007==a@B C%rc [US5n[URSS5S5nSnUH=upE[US5nUR5S:XdM'X#;a g[ SSU-5 M? X#;a[ SSU-5 gg) Nrr$r)i0rz content-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))rrrrr)r-r.codeNO_MESSAGE_BODYrrs rr(r(s vx 0F v||D!$Q' (D!O  }5 ::<> )* A9<@A B  "AGKL#rc r[USL=(d [U5[LSU<S[U5<35 g)Nz exc_info (z) is not a tuple: )rrr)r/s rr)r)s- H  7X% 7.6XGIrcN[[U[[45(+S5 g)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r isinstancerrLrs rr9r9s# 8c5\2 2 EFr)r __all__rerrcompilerrWarningrrrrr7r8r+rr:r6rrr&r'r(r)r9rrrrs iT -  JJ3 4 jj0' $H 5n77@88&44!?!?F?#B" # #C2M I Fr