§
    îŽ’joh  ã                  óX  — d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZ ddlmZmZ erddlmZ  ej        e¦  «        ZdZdZdZ dZ!d„  e"d¦  «        D ¦   «         Z#dZ$d0d„Z%d1d„Z&d2d#„Z'd3d'„Z(d4d+„Z) G d,„ d-¦  «        Z* G d.„ d/¦  «        Z+dS )5zL
Implements the HPACK header compression algorithm as detailed by RFC 7541.
é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyé   )ÚHPACKDecodingErrorÚInvalidTableSizeErrorÚOversizedHeaderListError)ÚHuffmanEncoder)ÚREQUEST_CODESÚREQUEST_CODES_LENGTH)Údecode_huffman)ÚHeaderTupleÚHeaderWeaklyTypedÚNeverIndexedHeaderTuple)ÚHeaderTableÚtable_entry_size)ÚIterableó    ó   ó   @é   c                ó   — g | ]
}d |z  dz
  ‘ŒS )é   r   © )Ú.0Úis     ú9C:\Projects\DSCons\.venv\Lib\site-packages\hpack\hpack.pyú
<listcomp>r      s    € Ð:Ð:Ð:¨A˜A ™F a™<Ð:Ð:Ð:ó    é	   i   Úheaderr   ÚrawÚboolÚreturnr   c                óþ   — t          | d         ¦  «        }t          | d         ¦  «        }|s<|                      |                     d¦  «        |                     d¦  «        ¦  «        S |                      ||¦  «        S )zj
    Provides a header as a unicode string if raw is False, otherwise returns
    it as a bytestring.
    r   r   úutf-8)ÚbytesÚ	__class__Údecode)r!   r"   ÚnameÚvalues       r   Ú_unicode_if_neededr,   %   ss   € õ
 �˜”ÑÔ€DÝ�&˜”)ÑÔ€Eàð MØ×Ò §¢¨GÑ 4Ô 4°e·l²lÀ7Ñ6KÔ6KÑLÔLÐLØ×Ò˜D %Ñ(Ô(Ð(r   ÚintegerÚintÚprefix_bitsÚ	bytearrayc                ó¤  — t                                d| |¦  «         | dk     rd| › �}t          |¦  «        ‚|dk     s|dk    rd|› �}t          |¦  «        ‚t          |         }| |k     rt	          | g¦  «        S |g}| |z  } | dk    r&|                     | dz  dz   ¦  «         | d	z  } | dk    °&|                     | ¦  «         t	          |¦  «        S )
zi
    Encodes an integer according to the wacky integer encoding rules
    defined in the HPACK spec.
    zEncoding %d with %d bitsr   z'Can only encode positive integers, got r   é   ú)Prefix bits must be between 1 and 8, got é€   é   é   )ÚlogÚdebugÚ
ValueErrorÚ_PREFIX_BIT_MAX_NUMBERSr0   Úappend)r-   r/   ÚmsgÚ
max_numberÚelementss        r   Úencode_integerr?   2   s÷   € õ
 ‡I‚IÐ(¨'°;Ñ?Ô?Ð?à�‚{€{ØA¸ÐAÐAˆÝ˜‰oŒoÐà�Q‚€˜+¨š/˜/ØG¸+ÐGÐGˆÝ˜‰oŒoÐå(¨Ô5€Jà�ÒÐÝ˜'˜Ñ#Ô#Ð#Øˆ|€HØˆzÑ€Gà
�SŠ.ˆ.Ø�Š˜ 3™¨#Ñ-Ñ.Ô.Ð.Ø�A‰ˆð �SŠ.ˆ.ð ‡O‚O�GÑÔÐå�XÑÔÐr   Údataúbytes | memoryviewútuple[int, int]c                óÄ  — |dk     s|dk    rd|› �}t          |¦  «        ‚t          |         }d}d}dd|z
  z	  }	 | d         |z  }||k    rN	 | |         }|dz  }|dk    r||dz
  |z  z  }n	|||z  z  }n%|dz  }|t          k    rd	| ›�}t          |¦  «        ‚ŒMn'# t          $ r}	d
| ›�}t          |¦  «        |	‚d}	~	ww xY wt
                               d||¦  «         ||fS )zï
    Decodes an integer according to the wacky integer encoding rules
    defined in the HPACK spec. Returns a tuple of the decoded integer and the
    number of bytes that were consumed from ``data`` in order to get that
    integer.
    r   r2   r3   r   éÿ   Tr4   r6   z-Variable integer representation is too long: z3Unable to decode HPACK integer representation from NzDecoded %d, consumed %d bytes)r9   r:   ÚVARINT_MAX_LENGTHr   Ú
IndexErrorr7   r8   )
r@   r/   r<   r=   ÚindexÚshiftÚmaskÚnumberÚ	next_byteÚerrs
             r   Údecode_integerrM   Q   sP  € ð �Q‚€˜+¨š/˜/ØG¸+ÐGÐGˆÝ˜‰oŒoÐå(¨Ô5€JØ€EØ€EØ�Q˜‘_Ñ%€Dð/Ø�a”˜4‘ˆØ�ZÒÐð2Ø  œK�	Ø˜‘
�à Ò#Ð#Ø˜y¨3™°5Ñ8Ñ8�F�Fà˜i¨5Ñ0Ñ0�FØØ˜‘
�àÕ,Ò,Ð,ð SÈ$ÐRÐR�CÝ,¨SÑ1Ô1Ð1ð)2øøõ, ð /ð /ð /ØLÀDÐLÐLˆÝ  Ñ%Ô%¨3Ð.øøøøð/øøøõ ‡I‚IÐ-¨v°uÑ=Ô=Ð=à�5ˆ=Ðs   »AB Â
B?Â%B:Â:B?Úheader_dictúdict[bytes | str, bytes | str]ú)Iterable[tuple[bytes | str, bytes | str]]c              #  óà   K  — t          | t          ¦  «        s!dt          | ¦  «        › �}t          |¦  «        ‚t	          |                      ¦   «         d„ ¬¦  «        }|D ]}|| |         fV — ŒdS )z¯
    Converts a dictionary to an iterable of key-value tuples. This is a
    HPACK-specific function because it pulls "special-headers" out first and
    then emits them.
    zheader_dict not a dict, but c                óH   — t          | ¦  «                             d¦  «         S )Nó   :)Ú	_to_bytesÚ
startswith)Úks    r   ú<lambda>z#_dict_to_iterable.<locals>.<lambda>�   s   € �) A™,œ,×1Ò1°$Ñ7Ô7Ð7€ r   )ÚkeyN)Ú
isinstanceÚdictÚtypeÚ	TypeErrorÚsortedÚkeys)rN   r<   r^   rX   s       r   Ú_dict_to_iterabler_   ƒ   s˜   è è € õ �k¥4Ñ(Ô(ð Ø@­T°+Ñ->Ô->Ð@Ð@ˆÝ˜‰nŒnÐåØ×ÒÑÔØ7Ð7ðñ ô €Dð ð $ð $ˆØ�;˜sÔ#Ð#Ð#Ð#Ð#Ð#ð$ð $r   r+   úbytes | str | Anyr'   c                ó�   — t          | ¦  «        }|t          u r| S |t          urt          | ¦  «        } |                      d¦  «        S )zB
    Convert anything to bytes through a UTF-8 encoded string
    r&   )r[   r'   ÚstrÚencode)r+   Úts     r   rT   rT   –   sC   € õ 	ˆU‰Œ€AØ�E€z€zØˆØ•€|€|Ý�E‘
”
ˆØ�<Š<˜Ñ Ô Ð r   c                  óŽ   — e Zd ZdZdd„Zedd„¦   «         Zej        dd„¦   «         Z	 d d!d„Zd"d#d„Z	d$d„Z
d"d%d„Zd"d&d„Zd'd„ZdS )(ÚEncoderzm
    An HPACK encoder object. This object takes HTTP headers and emits encoded
    HTTP/2 header blocks.
    r$   ÚNonec                óx   — t          ¦   «         | _        t          t          t          ¦  «        | _        g | _        d S ©N)r   Úheader_tabler
   r   r   Úhuffman_coderÚtable_size_changes©Úselfs    r   Ú__init__zEncoder.__init__¨   s6   € Ý'™MœMˆÔÝ+ÝÕ/ñ
ô 
ˆÔð .0ˆÔÐÐr   r.   c                ó   — | j         j        S ©z>
        Controls the size of the HPACK header table.
        ©rj   Úmaxsizerm   s    r   Úheader_table_sizezEncoder.header_table_size¯   ó   € ð
 Ô Ô(Ð(r   r+   c                ón   — || j         _        | j         j        r| j                             |¦  «         d S d S ri   )rj   rs   Úresizedrl   r;   ©rn   r+   s     r   rt   zEncoder.header_table_size¶   sB   € à$)ˆÔÔ!ØÔÔ$ð 	2ØÔ#×*Ò*¨5Ñ1Ô1Ð1Ð1Ð1ð	2ð 	2r   TÚheadersú‡Iterable[HeaderTuple | tuple[bytes | str, bytes | str] | tuple[bytes | str, bytes | str, bool | None]] | dict[bytes | str, bytes | str]Úhuffmanr#   r'   c                óz  — g }| j         j        r3|                     |                      ¦   «         ¦  «         d| j         _        t	          |t
          ¦  «        rt          |¦  «        }n	 t          |¦  «        }|D ]‘}d}t	          |t          ¦  «        r	|j	         }nt          |¦  «        dk    r|d         }t          |d         ¦  «        t          |d         ¦  «        f}|                     |                      |||¦  «        ¦  «         Œ’d                     |¦  «        }t                               d|¦  «         |S )a€	  
        Takes a set of headers and encodes them into a HPACK-encoded header
        block.

        :param headers: The headers to encode. Must be either an iterable of
                        tuples, an iterable of :class:`HeaderTuple
                        <hpack.HeaderTuple>`, or a ``dict``.

                        If an iterable of tuples, the tuples may be either
                        two-tuples or three-tuples. If they are two-tuples, the
                        tuples must be of the format ``(name, value)``. If they
                        are three-tuples, they must be of the format
                        ``(name, value, sensitive)``, where ``sensitive`` is a
                        boolean value indicating whether the header should be
                        added to header tables anywhere. If not present,
                        ``sensitive`` defaults to ``False``.

                        If an iterable of :class:`HeaderTuple
                        <hpack.HeaderTuple>`, the tuples must always be
                        two-tuples. Instead of using ``sensitive`` as a third
                        tuple entry, use :class:`NeverIndexedHeaderTuple
                        <hpack.NeverIndexedHeaderTuple>` to request that
                        the field never be indexed.

                        .. warning:: HTTP/2 requires that all special headers
                            (headers whose names begin with ``:`` characters)
                            appear at the *start* of the header block. While
                            this method will ensure that happens for ``dict``
                            subclasses, callers using any other iterable of
                            tuples **must** ensure they place their special
                            headers at the start of the iterable.

                            For efficiency reasons users should prefer to use
                            iterables of two-tuples: fixing the ordering of
                            dictionary headers is an expensive operation that
                            should be avoided if possible.

        :param huffman: (optional) Whether to Huffman-encode any header sent as
                        a literal value. Except for use when debugging, it is
                        recommended that this be left enabled.

        :returns: A bytestring containing the HPACK-encoded header block.
        Fr   r   r   r   zEncoded header block to %s)rj   rw   r;   Ú_encode_table_size_changerY   rZ   r_   Úiterr   Ú	indexableÚlenrT   ÚaddÚjoinr7   r8   )	rn   ry   r{   Úheader_blockÚhpack_headersr!   Ú	sensitiveÚ
new_headerÚencodeds	            r   rc   zEncoder.encode¼   s=  € ðp ˆð ÔÔ$ð 	.Ø×Ò × >Ò >Ñ @Ô @ÑAÔAÐAØ(-ˆDÔÔ%å�g�tÑ$Ô$ð 	*õ .¨gÑ6Ô6ˆMˆMðõ& ! ™MœMˆMð $ð 		Jð 		JˆFØˆIÝ˜&¥+Ñ.Ô.ð &à &Ô 0Ð0�	�	Ý�V‘”˜q’�Ø" 1œI�	å# F¨1¤IÑ.Ô.µ	¸&À¼)Ñ0DÔ0DÐEˆJØ×Ò §¢¨°YÀÑ HÔ HÑIÔIÐIÐIà—(’(˜<Ñ(Ô(ˆå�	Š	Ð.°Ñ8Ô8Ð8àˆr   FÚto_addútuple[bytes, bytes]r…   c                óÆ  — |\  }}|s|nd}t                                d||||¦  «         |st          nt          }| j                             ||¦  «        }|€7|                      ||||¦  «        }	|s| j                             ||¦  «         |	S |\  }
}}|�|                      |
¦  «        }	n5|  	                    |
|||¦  «        }	|s| j                             ||¦  «         |	S )a}  
        Serializes a header key-value tuple.

        When sensitive is True, the header will not be added to the header table
        (see https://www.rfc-editor.org/rfc/rfc7541.html#section-7.1.3 for details),
        furthermore, the header value will be redacted in debug logs, as "SENSITIVE_REDACTED",
        to prevent accidental exposure of sensitive information.
        s   SENSITIVE_REDACTEDz:Adding %s=%s to the header table, sensitive:%s, huffman:%s)
r7   r8   ÚINDEX_INCREMENTALÚINDEX_NEVERrj   ÚsearchÚ_encode_literalr�   Ú_encode_indexedÚ_encode_indexed_literal)rn   rˆ   r…   r{   r*   r+   Údisplay_valueÚindexbitÚmatchr‡   rG   Úperfects               r   r�   zEncoder.add)  s$  € ð ‰ˆˆeà%.ÐI˜˜Ð4IˆÝ�	Š	ØHØØØØñ	
ô 	
ð 	
ð -6ÐFÕ$Ð$½;ˆð Ô!×(Ò(¨¨uÑ5Ô5ˆàˆ=ð ×*Ò*¨4°¸À'ÑJÔJˆGØð 3ØÔ!×%Ò% d¨EÑ2Ô2Ð2ØˆNð
  %Ñˆˆt�WàÐà×*Ò*¨5Ñ1Ô1ˆGˆGð ×2Ò2Ø�u˜h¨ñô ˆGð ð 3ØÔ!×%Ò% d¨EÑ2Ô2Ð2àˆr   rG   c                ó`   — t          |d¦  «        }|dxx         dz  cc<   t          |¦  «        S )zD
        Encodes a header using the indexed representation.
        r6   r   r4   )r?   r'   )rn   rG   Úfields      r   r�   zEncoder._encode_indexeda  s5   € õ ˜u aÑ(Ô(ˆØˆaˆˆŒ�DÑˆˆ‰Ý�U‰|Œ|Ðr   r*   r’   c                óŽ  — |r4| j                              |¦  «        }| j                              |¦  «        }t          t          |¦  «        d¦  «        }t          t          |¦  «        d¦  «        }|r |dxx         dz  cc<   |dxx         dz  cc<   d                     |t          |¦  «        |t          |¦  «        |g¦  «        S )z·
        Encodes a header with a literal name and literal value. If ``indexing``
        is True, the header will be added to the header table: otherwise it
        will not.
        r6   r   r4   r   )rk   rc   r?   r€   r‚   r'   )rn   r*   r+   r’   r{   Úname_lenÚ	value_lens          r   rŽ   zEncoder._encode_literali  sÈ   € ð ð 	5ØÔ%×,Ò,¨TÑ2Ô2ˆDØÔ&×-Ò-¨eÑ4Ô4ˆEå!¥# d¡)¤)¨QÑ/Ô/ˆÝ"¥3 u¡:¤:¨qÑ1Ô1ˆ	àð 	!Ø�QˆKˆKŒK˜4ÑˆKˆK‰KØ�aˆLˆLŒL˜DÑ ˆLˆL‰Là�xŠxØ•u˜X‘”¨­e°IÑ.>Ô.>ÀÐFñ
ô 
ð 	
r   c                óŽ  — |t           k    rt          |d¦  «        }nt          |d¦  «        }|dxx         t          |¦  «        z  cc<   |r| j                             |¦  «        }t          t          |¦  «        d¦  «        }|r|dxx         dz  cc<   d                     t          |¦  «        t          |¦  «        |g¦  «        S )zv
        Encodes a header with an indexed name and a literal value and performs
        incremental indexing.
        é   é   r   r6   r4   r   )r‹   r?   Úordrk   rc   r€   r‚   r'   )rn   rG   r+   r’   r{   Úprefixr™   s          r   r�   zEncoder._encode_indexed_literal~  sÄ   € ð
 Õ(Ò(Ð(Ý# E¨1Ñ-Ô-ˆFˆFå# E¨1Ñ-Ô-ˆFàˆqˆ	ˆ	Œ	•S˜‘]”]Ñ"ˆ	ˆ	‰	àð 	5ØÔ&×-Ò-¨eÑ4Ô4ˆEå"¥3 u¡:¤:¨qÑ1Ô1ˆ	àð 	!Ø�aˆLˆLŒL˜DÑ ˆLˆL‰Là�xŠx�˜v™œ­¨iÑ(8Ô(8¸%Ð@ÑAÔAÐAr   c                ó�   — d}| j         D ]4}t          |d¦  «        }|dxx         dz  cc<   |t          |¦  «        z  }Œ5g | _         |S )zd
        Produces the encoded form of all header table size change context
        updates.
        r   r   r   é    )rl   r?   r'   )rn   ÚblockÚ
size_bytesÚbs       r   r}   z!Encoder._encode_table_size_change”  s^   € ð
 ˆØÔ1ð 	ð 	ˆJÝ˜z¨1Ñ-Ô-ˆAØˆaˆDˆDŒD�D‰LˆDˆD‰DØ•U˜1‘X”XÑˆEˆEØ"$ˆÔØˆr   N©r$   rg   ©r$   r.   ©r+   r.   r$   rg   )T)ry   rz   r{   r#   r$   r'   ©F)rˆ   r‰   r…   r#   r{   r#   r$   r'   )rG   r.   r$   r'   )
r*   r'   r+   r'   r’   r'   r{   r#   r$   r'   )
rG   r.   r+   r'   r’   r'   r{   r#   r$   r'   )r$   r'   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ro   Úpropertyrt   Úsetterrc   r�   r�   rŽ   r�   r}   r   r   r   rf   rf   ¢   s  € € € € € ðð ð
0ð 0ð 0ð 0ð ð)ð )ð )ñ „Xð)ð Ôð2ð 2ð 2ñ Ôð2ð  $ðkð kð kð kð kðZ6ð 6ð 6ð 6ð 6ðpð ð ð ð
ð 
ð 
ð 
ð 
ð*Bð Bð Bð Bð Bð,ð ð ð ð ð r   rf   c                  ó’   — e Zd ZdZefdd„Zedd„¦   «         Zej        dd	„¦   «         Zddd„Z	d d„Z
d!d„Zd"d„Zd"d„Zd"d„Zd#d„ZdS )$ÚDecodera  
    An HPACK decoder object.

    .. versionchanged:: 2.3.0
       Added ``max_header_list_size`` argument.

    :param max_header_list_size: The maximum decompressed size we will allow
        for any single header block. This is a protection against DoS attacks
        that attempt to force the application to expand a relatively small
        amount of data into a really large header list, allowing enormous
        amounts of memory to be allocated.

        If this amount of data is exceeded, a `OversizedHeaderListError
        <hpack.OversizedHeaderListError>` exception will be raised. At this
        point the connection should be shut down, as the HPACK state will no
        longer be usable.

        Defaults to 64kB.
    :type max_header_list_size: ``int``
    Úmax_header_list_sizer.   r$   rg   c                ó\   — t          ¦   «         | _        || _        | j        j        | _        d S ri   )r   rj   r°   rs   Úmax_allowed_table_size)rn   r°   s     r   ro   zDecoder.__init__¸  s.   € Ý'™MœMˆÔð  %9ˆÔ!ð '+Ô&7Ô&?ˆÔ#Ð#Ð#r   c                ó   — | j         j        S rq   rr   rm   s    r   rt   zDecoder.header_table_sizeÔ  ru   r   r+   c                ó   — || j         _        d S ri   rr   rx   s     r   rt   zDecoder.header_table_sizeÛ  s   € à$)ˆÔÔ!Ð!Ð!r   Fr@   r'   r"   r#   úIterable[HeaderTuple]c                óž  ‡— t                                d|¦  «         t          |¦  «        }g }t          |¦  «        }d}d}||k     �r@||         }t	          |dz  ¦  «        }	t	          |dz  ¦  «        }
t	          |dz  ¦  «        }|	r!|                      ||d…         ¦  «        \  }}nx|
r!|                      ||d…         ¦  «        \  }}nU|r3|rd}t          |¦  «        ‚|                      ||d…         ¦  «        }d}n |  	                    ||d…         ¦  «        \  }}|rY| 
                    |¦  «         |t          |d         |d         ¦  «        z  }|| j        k    rd	| j        › d
�}t          |¦  «        ‚||z  }||k     �°@|                      ¦   «          	 ˆfd„|D ¦   «         S # t          $ r}d}t          |¦  «        |‚d}~ww xY w)aê  
        Takes an HPACK-encoded header block and decodes it into a header set.

        :param data: A bytestring representing a complete HPACK-encoded header
                     block.
        :param raw: (optional) Whether to return the headers as tuples of raw
                    byte strings or to decode them as UTF-8 before returning
                    them. The default value is False, which returns tuples of
                    Unicode strings
        :returns: A list of two-tuples of ``(name, value)`` representing the
                  HPACK-encoded headers, in the order they were decoded.
        :raises HPACKDecodingError: If an error is encountered while decoding
                                    the header block.
        zDecoding %sr   r4   é@   r    Nz/Table size update not at the start of the blockr   zA header list larger than z has been receivedc                ó0   •— g | ]}t          |‰¦  «        ‘ŒS r   )r,   )r   Úhr"   s     €r   r   z"Decoder.decode.<locals>.<listcomp>-  s$   ø€ Ð@Ð@Ð@°1Õ& q¨#Ñ.Ô.Ð@Ð@Ð@r   z!Unable to decode headers as UTF-8)r7   r8   Ú
memoryviewr€   r#   Ú_decode_indexedÚ_decode_literal_indexr   Ú_update_encoding_contextÚ_decode_literal_no_indexr;   r   r°   r	   Ú_assert_valid_table_sizeÚUnicodeDecodeError)rn   r@   r"   Údata_memry   Údata_lenÚinflated_sizeÚcurrent_indexÚcurrentÚindexedÚliteral_indexÚencoding_updater!   Úconsumedr<   rL   s     `             r   r)   zDecoder.decodeß  sQ  ø€ õ 	�	Š	�- Ñ&Ô&Ð&å˜dÑ#Ô#ˆØ%'ˆÝ�t‘9”9ˆØˆØˆà˜hÒ&Ñ&ð ˜=Ô)ˆGÝ˜7 T™>Ñ*Ô*ˆGõ ! ¨4¡Ñ0Ô0ˆMõ # 7¨T¡>Ñ2Ô2ˆOàð Ø#'×#7Ò#7Ø˜]˜^˜^Ô,ñ$ô $Ñ �˜˜ð ð à#'×#=Ò#=Ø˜]˜^˜^Ô,ñ$ô $Ñ �˜˜ð !ð ð ð 2ØK�CÝ,¨SÑ1Ô1Ð1Ø×8Ò8Ø˜]˜^˜^Ô,ñô �ð ��ð $(×#@Ò#@Ø˜]˜^˜^Ô,ñ$ô $Ñ �˜ð ð 8Ø—’˜vÑ&Ô&Ð&ØÕ!1°&¸´)¸VÀA¼YÑ!GÔ!GÑG�à  4Ô#<Ò<Ð<Ød°tÔ7PÐdÐdÐd�CÝ2°3Ñ7Ô7Ð7à˜XÑ%ˆMð_ ˜hÒ&Ñ&ðh 	×%Ò%Ñ'Ô'Ð'ð	3Ø@Ð@Ð@Ð@¸Ð@Ñ@Ô@Ð@øÝ!ð 	3ð 	3ð 	3Ø5ˆCÝ$ SÑ)Ô)¨sÐ2øøøøð	3øøøs   ÆF+ Æ+
GÆ5GÇGc                óH   — | j         | j        k    rd}t          |¦  «        ‚dS )zs
        Check that the table size set by the encoder is lower than the maximum
        we expect to have.
        z3Encoder did not shrink table size to within the maxN)rt   r²   r   )rn   r<   s     r   r¿   z Decoder._assert_valid_table_size2  s1   € ð
 Ô! DÔ$?Ò?Ð?ØGˆCÝ'¨Ñ,Ô,Ð,ð @Ð?r   rA   c                ór   — t          |d¦  «        \  }}|| j        k    rd}t          |¦  «        ‚|| _        |S )zC
        Handles a byte that updates the encoding context.
        r   z)Encoder exceeded max allowable table size)rM   r²   r   rt   )rn   r@   Únew_sizerÉ   r<   s        r   r½   z Decoder._update_encoding_context;  sF   € õ
 ,¨D°!Ñ4Ô4Ñˆ�(Ø�dÔ1Ò1Ð1Ø=ˆCÝ'¨Ñ,Ô,Ð,Ø!)ˆÔØˆr   útuple[HeaderTuple, int]c                óª   — t          |d¦  «        \  }}t          | j                             |¦  «        Ž }t                               d||¦  «         ||fS )zP
        Decodes a header represented using the indexed representation.
        r6   zDecoded %s, consumed %d)rM   r   rj   Úget_by_indexr7   r8   )rn   r@   rG   rÉ   r!   s        r   r»   zDecoder._decode_indexedG  sT   € õ )¨¨qÑ1Ô1‰ˆˆxÝ˜dÔ/×<Ò<¸UÑCÔCÐDˆÝ�	Š	Ð+¨V°XÑ>Ô>Ð>Ø�xÐÐr   c                ó0   — |                       |d¬¦  «        S )NF©Úshould_index©Ú_decode_literal©rn   r@   s     r   r¾   z Decoder._decode_literal_no_indexP  s   € Ø×#Ò# D°uÐ#Ñ=Ô=Ð=r   c                ó0   — |                       |d¬¦  «        S )NTrÑ   rÓ   rÕ   s     r   r¼   zDecoder._decode_literal_indexS  s   € Ø×#Ò# D°tÐ#Ñ<Ô<Ð<r   rÒ   c                óº  — t          |t          ¦  «        r|                     ¦   «         }d}|r|d         dz  }d}d}n!|d         }|dz  }d}t          |dz  ¦  «        }|r8t	          ||¦  «        \  }}	| j                             |¦  «        d         }
|	}d}np|dd	…         }t	          |d
¦  «        \  }}	||	|	|z   …         }
t          |
¦  «        |k    rd}t          |¦  «        ‚|d         dz  rt          |
¦  «        }
|	|z   dz   }||	|z   d	…         }t	          |d
¦  «        \  }}	||	|	|z   …         }t          |¦  «        |k    rd}t          |¦  «        ‚|d         dz  rt          |¦  «        }|||	z   z  }|rt          |
|¦  «        }nt          |
|¦  «        }|r| j                             |
|¦  «         t                               d|||¦  «         ||fS )z>
        Decodes a header represented with a literal.
        r   é?   rœ   Fé   r›   é   r   Nr6   zTruncated header blockr4   z/Decoded %s, total consumed %d bytes, indexed %s)rY   rº   Útobytesr#   rM   rj   rÏ   r€   r   r   r   r   r�   r7   r8   )rn   r@   rÒ   Útotal_consumedÚindexed_namer˜   Únot_indexableÚ	high_byterG   rÉ   r*   Úlengthr<   r+   r!   s                  r   rÔ   zDecoder._decode_literalV  sK  € õ �d�JÑ'Ô'ð 	"Ø—<’<‘>”>ˆDàˆð ð 	3Ø œ7 T™>ˆLØˆHØ!ˆMˆMà˜QœˆIØ$ tÑ+ˆLØˆHÝ  ¨TÑ!1Ñ2Ô2ˆMàð 	3å,¨T°8Ñ<Ô<‰OˆE�8ØÔ$×1Ò1°%Ñ8Ô8¸Ô;ˆDà%ˆNØˆFˆFð ˜˜˜”8ˆDå-¨d°AÑ6Ô6ÑˆF�HØ˜ ¨FÑ!2Ð2Ô3ˆDÝ�4‰yŒy˜FÒ"Ð"Ø.�Ý(¨Ñ-Ô-Ð-à�AŒw˜‰~ð ,Ý% dÑ+Ô+�Ø%¨Ñ.°Ñ2ˆNà�H˜vÑ%Ð&Ð&Ô'ˆõ *¨$°Ñ2Ô2Ñˆ�Ø�X˜h¨Ñ/Ð/Ô0ˆÝˆu‰:Œ:˜ÒÐØ*ˆCÝ$ SÑ)Ô)Ð)à�Œ7�T‰>ð 	*Ý" 5Ñ)Ô)ˆEð 	˜& 8Ñ+Ñ+ˆð
 ð 	.Ý,¨T°5Ñ9Ô9ˆFˆFå   uÑ-Ô-ˆFð ð 	/ØÔ×!Ò! $¨Ñ.Ô.Ð.å�	Š	Ø=ØØØñ		
ô 	
ð 	
ð �~Ð%Ð%r   N)r°   r.   r$   rg   r¥   r¦   r§   )r@   r'   r"   r#   r$   rµ   r¤   )r@   rA   r$   r.   )r@   rA   r$   rÍ   )r@   rA   rÒ   r#   r$   rÍ   )r¨   r©   rª   r«   ÚDEFAULT_MAX_HEADER_LIST_SIZEro   r¬   rt   r­   r)   r¿   r½   r»   r¾   r¼   rÔ   r   r   r   r¯   r¯   ¢  s#  € € € € € ðð ð* 4Pð @ð @ð @ð @ð @ð8 ð)ð )ð )ñ „Xð)ð Ôð*ð *ð *ñ Ôð*ðQ3ð Q3ð Q3ð Q3ð Q3ðf-ð -ð -ð -ð
ð 
ð 
ð 
ð ð  ð  ð  ð>ð >ð >ð >ð=ð =ð =ð =ðO&ð O&ð O&ð O&ð O&ð O&r   r¯   )r!   r   r"   r#   r$   r   )r-   r.   r/   r.   r$   r0   )r@   rA   r/   r.   r$   rB   )rN   rO   r$   rP   )r+   r`   r$   r'   ),r«   Ú
__future__r   ÚloggingÚtypingr   r   Ú
exceptionsr   r   r	   r{   r
   Úhuffman_constantsr   r   Úhuffman_tabler   Ústructr   r   r   Útabler   r   Úcollections.abcr   Ú	getLoggerr¨   r7   Ú
INDEX_NONErŒ   r‹   rE   Úranger:   rá   r,   r?   rM   r_   rT   rf   r¯   r   r   r   ú<module>rî      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ø #Ð #Ð #Ð #Ð #Ð #Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ )Ð )Ð )Ð )Ð )Ð )Ø KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0àð )Ø(Ð(Ð(Ð(Ð(Ð(à€gÔ˜Ñ!Ô!€à€
Ø€ØÐ àÐ ð
 ;Ð:°°°q±´Ð:Ñ:Ô:Ð ð  'Ð ð
)ð 
)ð 
)ð 
)ðð ð ð ð>/ð /ð /ð /ðd$ð $ð $ð $ð&	!ð 	!ð 	!ð 	!ð}ð }ð }ð }ð }ñ }ô }ð }ð@C&ð C&ð C&ð C&ð C&ñ C&ô C&ð C&ð C&ð C&r   