
    |h                     >   d Z ddlZddlZddlmZ ddlmZ dZdeiZ	d Z
 e
        [
dej                  fd	Zdej                  fd
Z G d dej                        Z G d dej                  ej                           Z e       Zej$                  Zej&                  Zy)z'Falcon request argument parsing module.    N)parse_query_string)corez422 Unprocessable Entityi  c                      t        d t        t        j                              D ]B  } t	        t        j                  |       }t        |j                  d      d         }|t        |<   D y )Nc                 $    | j                  d      S )NHTTP)
startswith)ns    S/var/www/html/test/engine/venv/lib/python3.12/site-packages/webargs/falconparser.py<lambda>z"_find_exceptions.<locals>.<lambda>   s    f!5      r   )filterdirfalconstatus_codesgetattrintsplit
status_map)namestatusstatus_codes      r
   _find_exceptionsr      sX    5s6;N;N7OP ),,d3&,,s+A./"(
;)r   reqc                 V    | j                  d      }|xr t        j                  |      S )NzContent-Type)
get_headerr   is_json)r   content_types     r
   is_json_requestr      s$    >>.1L6DLL66r   c                 V   | j                   ld| j                   v r^| j                  j                  | j                  xs d      }	 |j	                  d      }|r!t        || j                  j                        S t        j                  S # t
        $ r d }| j                  d       Y Qw xY w)Nz!application/x-www-form-urlencodedr   asciizuNon-ASCII characters found in form body with Content-Type of application/x-www-form-urlencoded. Body will be ignored.)
keep_blank)r   streamreadcontent_lengthdecodeUnicodeDecodeError	log_errorr   optionskeep_blank_qs_valuesr   missing)r   bodys     r
   parse_form_bodyr-   !   s    $/33C3CCzzs116Q7		;;w'D %ds{{7W7WXX<< " 	DMM#	s   B	 	B('B(c                   ,     e Zd ZdZ fdZ fdZ xZS )	HTTPErrorz@HTTPError that stores a dictionary of validation error messages.c                 :    || _         t        |   |g|i | y )N)errorssuper__init__)selfr   r1   argskwargs	__class__s        r
   r3   zHTTPError.__init__;   s!    1$1&1r   c                 \    t        |   |i |}| j                  | j                  |d<   |S )zCOverride `falcon.HTTPError` to include error messages in responses.r1   )r2   to_dictr1   )r4   r5   r6   retr7   s       r
   r9   zHTTPError.to_dict?   s2    got.v.;;" KKCM
r   )__name__
__module____qualname____doc__r3   r9   __classcell__)r7   s   @r
   r/   r/   8   s    J2 r   r/   c                      e Zd ZdZdZ eddej                  iej                  j                  Z
 edddiej                  j                  Zdej                  fdZdej                  fdZdej                  fdZdej                  fdZdej                  fd	Zdej                  fd
Zd Zdej                  fdZdej                  fdZdej                  fdZy)FalconParserzFalcon request argument parser.

    Defaults to using the `media` location. See :py:meth:`~FalconParser.load_media` for
    details on the media location.media
load_mediar   c                 :    | j                  |j                  |      S )z9Return query params from the request as a MultiDictProxy.)
_makeproxyparamsr4   r   schemas      r
   load_querystringzFalconParser.load_querystring`   s    szz622r   c                 d    t        |      }|t        j                  u r|S | j                  ||      S )zReturn form values from the request as a MultiDictProxy

        .. note::

            The request stream will be read and left at EOF.
        )r-   r   r+   rE   )r4   r   rH   forms       r
   	load_formzFalconParser.load_formd   s0     s#4<<KtV,,r   c                 V    |j                   dv rt        j                  S |j                  S )a  Return data unpacked and parsed by one of Falcon's media handlers.
        By default, Falcon only handles JSON payloads.

        To configure additional media handlers, see the
        `Falcon documentation on media types`__.

        .. _FalconMedia: https://falcon.readthedocs.io/en/stable/api/media.html
        __ FalconMedia_

        .. note::

            The request stream will be read and left at EOF.
        Nr   )r%   r   r+   rB   rG   s      r
   rC   zFalconParser.load_mediap   s&     *<<yyr   c                     t        |      r|j                  dv rt        j                  S |j                  j                  |j                        }|rt        j                  |      S t        j                  S )zReturn a json payload from the request for the core parser's load_json

        Checks the input mimetype and may return 'missing' if the mimetype is
        non-json, even if the request body is parseable as json.rN   )r   r%   r   r+   r#   r$   
parse_json)r4   r   r,   s      r
   _raw_load_jsonzFalconParser._raw_load_json   sW    
 s#s'9'9Y'F<<zzs112??4((||r   c                     |j                   S )z Return headers from the request.)headersrG   s      r
   load_headerszFalconParser.load_headers   s     {{r   c                     |j                   S )z Return cookies from the request.)cookiesrG   s      r
   load_cookieszFalconParser.load_cookies   s     {{r   c                 Z    |d   }t        |t        j                        st        d      |S )zmGet request from a resource method's arguments. Assumes that
        request is the second argument.
           z Argument is not a falcon.Request)
isinstancer   Request	TypeError)r4   viewr5   r6   r   s        r
   get_request_from_view_argsz'FalconParser.get_request_from_view_args   s,     1g#v~~.>??
r   c                 F    t        d| j                  j                         )Nz#Parsing files not yet supported by )NotImplementedErrorr7   r;   rG   s      r
   
load_fileszFalconParser.load_files   s$    !1$..2I2I1JK
 	
r   c                    t         j                  |xs | j                        }|t        d| d      t	        ||j
                  |      )zHandles errors during parsing.zStatus code z not supported)r1   rS   )r   getDEFAULT_VALIDATION_STATUSLookupErrorr/   messages)r4   errorr   rH   error_status_codeerror_headersr   s          r
   handle_errorzFalconParser.handle_error   sL      1 ST5S5ST>->,?~NOOu~~}MMr   c                 8    t         d   }ddgi}t        ||      )Ni  jsonzInvalid JSON body.)r1   )r   r/   )r4   rg   r   r5   r6   r   rf   s          r
   _handle_invalid_json_errorz'FalconParser._handle_invalid_json_error   s&    C123x00r   N )r;   r<   r=   r>   DEFAULT_LOCATIONdictmaRAISEr   ParserDEFAULT_UNKNOWN_BY_LOCATION__location_map__r   r[   rI   rL   rC   rQ   rT   rW   r^   ra   rj   rm   rn   r   r
   rA   rA   G   s    & "& #hh#++AA# O,O$++2N2NO3FNN 3
-V^^ 
-fnn &
&.. 
 
 
fnn 

N ..N1V^^ 1r   rA   )r>   r   marshmallowrq   falcon.util.urir   webargsr   HTTP_422r   r   r[   r   r-   r/   rs   rA   parseruse_args
use_kwargsrn   r   r
   <module>r}      s    -   . % 8_
)  7 7 .   o14;;v~~. o1d 
??
r   