
    g                     `    d Z ddlZ G d d      Z G d d      Z G d d      Z G d	 d
      Zy)zU
h2/config
~~~~~~~~~

Objects for controlling the configuration of the HTTP/2 stack.
    Nc                   "    e Zd ZdZd Zd Zd Zy)_BooleanConfigOptionz
    Descriptor for handling a boolean config option.  This will block
    attempts to set boolean config options to non-bools.
    c                 :    || _         d| j                   z  | _        y )Nz_%s)name	attr_name)selfr   s     >/var/www/openai/venv/lib/python3.12/site-packages/h2/config.py__init__z_BooleanConfigOption.__init__   s    	*    c                 .    t        || j                        S N)getattrr   )r   instanceowners      r	   __get__z_BooleanConfigOption.__get__   s    x00r   c                     t        |t              st        d| j                  z        t	        || j
                  |       y )Nz%s must be a bool)
isinstancebool
ValueErrorr   setattrr   )r   r   values      r	   __set__z_BooleanConfigOption.__set__   s1    %&0499<==$..%0r   N)__name__
__module____qualname____doc__r
   r   r    r   r	   r   r      s    +11r   r   c                   "    e Zd ZdZd Zd Zd Zy)DummyLoggera.  
    A Logger object that does not actual logging, hence a DummyLogger.

    For the class the log operation is merely a no-op. The intent is to avoid
    conditionals being sprinkled throughout the h2 code for calls to
    logging functions when no logger is passed into the corresponding object.
    c                      y r   r   )r   vargss     r	   r
   zDummyLogger.__init__&   s    r   c                      yz;
        No-op logging. Only level needed for now.
        Nr   r   r!   kwargss      r	   debugzDummyLogger.debug)        	r   c                      yr#   r   r$   s      r	   tracezDummyLogger.trace/   r'   r   N)r   r   r   r   r
   r&   r)   r   r   r	   r   r      s    r   r   c                   0     e Zd ZdZd fd	Zd Zd Z xZS )OutputLoggeraF  
    A Logger object that prints to stderr or any other file-like object.

    This class is provided for convenience and not part of the stable API.

    :param file: A file-like object passed to the print function.
        Defaults to ``sys.stderr``.
    :param trace: Enables trace-level output. Defaults to ``False``.
    c                 b    t         |           |xs t        j                  | _        || _        y r   )superr
   sysstderrfiletrace_level)r   r0   r1   	__class__s      r	   r
   zOutputLogger.__init__@   s&    &CJJ	&r   c                 >    t        d||z   | j                         y )Nzh2 (debug): r0   )printr0   r   fmtstrargss      r	   r&   zOutputLogger.debugE   s    Vd]O,499=r   c                 X    | j                   rt        d||z   | j                         y y )Nzh2 (trace): r4   )r1   r5   r0   r6   s      r	   r)   zOutputLogger.traceH   s)    L$0tyyA r   )NF)r   r   r   r   r
   r&   r)   __classcell__)r2   s   @r	   r+   r+   6   s    '
>Br   r+   c                       e Zd ZdZ ed      Z ed      Z ed      Z ed      Z ed      Z		 	 	 	 	 	 	 ddZ
ed	        Zej                  d
        Zy)H2Configurationa4  
    An object that controls the way a single HTTP/2 connection behaves.

    This object allows the users to customize behaviour. In particular, it
    allows users to enable or disable optional features, or to otherwise handle
    various unusual behaviours.

    This object has very little behaviour of its own: it mostly just ensures
    that configuration is self-consistent.

    :param client_side: Whether this object is to be used on the client side of
        a connection, or on the server side. Affects the logic used by the
        state machine, the default settings values, the allowable stream IDs,
        and several other properties. Defaults to ``True``.
    :type client_side: ``bool``

    :param header_encoding: Controls whether the headers emitted by this object
        in events are transparently decoded to ``unicode`` strings, and what
        encoding is used to do that decoding. This defaults to ``None``,
        meaning that headers will be returned as bytes. To automatically
        decode headers (that is, to return them as unicode strings), this can
        be set to the string name of any encoding, e.g. ``'utf-8'``.

        .. versionchanged:: 3.0.0
           Changed default value from ``'utf-8'`` to ``None``

    :type header_encoding: ``str``, ``False``, or ``None``

    :param validate_outbound_headers: Controls whether the headers emitted
        by this object are validated against the rules in RFC 7540.
        Disabling this setting will cause outbound header validation to
        be skipped, and allow the object to emit headers that may be illegal
        according to RFC 7540. Defaults to ``True``.
    :type validate_outbound_headers: ``bool``

    :param normalize_outbound_headers: Controls whether the headers emitted
        by this object are normalized before sending.  Disabling this setting
        will cause outbound header normalization to be skipped, and allow
        the object to emit headers that may be illegal according to
        RFC 7540. Defaults to ``True``.
    :type normalize_outbound_headers: ``bool``

    :param validate_inbound_headers: Controls whether the headers received
        by this object are validated against the rules in RFC 7540.
        Disabling this setting will cause inbound header validation to
        be skipped, and allow the object to receive headers that may be illegal
        according to RFC 7540. Defaults to ``True``.
    :type validate_inbound_headers: ``bool``

    :param normalize_inbound_headers: Controls whether the headers received by
        this object are normalized according to the rules of RFC 7540.
        Disabling this setting may lead to h2 emitting header blocks that
        some RFCs forbid, e.g. with multiple cookie fields.

        .. versionadded:: 3.0.0

    :type normalize_inbound_headers: ``bool``

    :param logger: A logger that conforms to the requirements for this module,
        those being no I/O and no context switches, which is needed in order
        to run in asynchronous operation.

        .. versionadded:: 2.6.0

    :type logger: ``logging.Logger``
    client_sidevalidate_outbound_headersnormalize_outbound_headersvalidate_inbound_headersnormalize_inbound_headersNc                     || _         || _        || _        || _        || _        || _        |xs t        t              | _        y r   )	r=   header_encodingr>   r?   r@   rA   r   r   logger)r   r=   rC   r>   r?   r@   rA   rD   s           r	   r
   zH2Configuration.__init__   sE     '.)B&*D'(@%)B&5H 5r   c                     | j                   S )a  
        Controls whether the headers emitted by this object in events are
        transparently decoded to ``unicode`` strings, and what encoding is used
        to do that decoding. This defaults to ``None``, meaning that headers
        will be returned as bytes. To automatically decode headers (that is, to
        return them as unicode strings), this can be set to the string name of
        any encoding, e.g. ``'utf-8'``.
        )_header_encoding)r   s    r	   rC   zH2Configuration.header_encoding   s     $$$r   c                     t        |t        t        t        d      f      st	        d      |du rt	        d      || _        y)zG
        Enforces constraints on the value of header encoding.
        Nz-header_encoding must be bool, string, or NoneTzheader_encoding cannot be True)r   r   strtyper   rF   )r   r   s     r	   rC   zH2Configuration.header_encoding   s@    
 %$T$Z!89LMMD==>> %r   )TNTTTTN)r   r   r   r   r   r=   r>   r?   r@   rA   r
   propertyrC   setterr   r   r	   r<   r<   M   s    AD '}5K 4#! "6$"  4"  !5#!
 "!%+/,0*.+/6  	% 	% & &r   r<   )r   r.   r   r   r+   r<   r   r   r	   <module>rL      s;    1 1$ 0B B.v& v&r   