§
    ±eîiÂ_  ã                  óT  — 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„  e!d¦  «        D ¦   «         Z"dZ#d.d„Z$d/d„Z%d0d"„Z&d1d&„Z'd2d)„Z( G d*„ d+¦  «        Z) G d,„ d-¦  «        Z*dS )3zL
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     úO/home/div/.hermes/hermes-agent/venv/lib/python3.11/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_NUMBERSr/   Úappend)r,   r.   ÚmsgÚ
max_numberÚelementss        r   Úencode_integerr>   0   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   Údatar&   útuple[int, int]c                ó†  — |dk     s|dk    rd|› �}t          |¦  «        ‚t          |         }d}d}dd|z
  z	  }	 | d         |z  }||k    r/	 | |         }|dz  }|dk    r||dz
  |z  z  }n	|||z  z  }n|dz  }Œ.n'# 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   r1   r2   r   éÿ   Tr3   r5   z3Unable to decode HPACK integer representation from NzDecoded %d, consumed %d bytes)r8   r9   Ú
IndexErrorr   r6   r7   )
r?   r.   r;   r<   ÚindexÚshiftÚmaskÚnumberÚ	next_byteÚerrs
             r   Údecode_integerrJ   O   s&  € ð �Q‚€˜+¨š/˜/ØG¸+ÐGÐGˆÝ˜‰oŒoÐå(¨Ô5€JØ€EØ€EØ�Q˜‘_Ñ%€Dð/Ø�a”˜4‘ˆØ�ZÒÐð	Ø  œK�	Ø˜‘
�à Ò#Ð#Ø˜y¨3™°5Ñ8Ñ8�F�Fà˜i¨5Ñ0Ñ0�FØØ˜‘
�ð	øøõ ð /ð /ð /ØLÀDÐLÐLˆÝ  Ñ%Ô%¨3Ð.øøøøð/øøøõ ‡I‚IÐ-¨v°uÑ=Ô=Ð=à�5ˆ=Ðs   »A A< Á<
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)rK   r;   r[   rU   s       r   Ú_dict_to_iterabler\   v   s˜   è è € õ �k¥4Ñ(Ô(ð Ø@­T°+Ñ->Ô->Ð@Ð@ˆÝ˜‰nŒnÐåØ×ÒÑÔØ7Ð7ðñ ô €Dð ð $ð $ˆØ�;˜sÔ#Ð#Ð#Ð#Ð#Ð#ð$ð $r   r*   úbytes | str | Anyc                ó�   — t          | ¦  «        }|t          u r| S |t          urt          | ¦  «        } |                      d¦  «        S )zB
    Convert anything to bytes through a UTF-8 encoded string
    r%   )rX   r&   ÚstrÚencode)r*   Úts     r   rQ   rQ   ‰   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.
        ©rg   Úmaxsizerj   s    r   Úheader_table_sizezEncoder.header_table_size¢   ó   € ð
 Ô Ô(Ð(r   r*   c                ón   — || j         _        | j         j        r| j                             |¦  «         d S d S rf   )rg   rp   Úresizedri   r:   ©rk   r*   s     r   rq   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)rg   rt   r:   Ú_encode_table_size_changerV   rW   r\   Úiterr   Ú	indexableÚlenrQ   ÚaddÚjoinr6   r7   )	rk   rv   rx   Úheader_blockÚhpack_headersr    Ú	sensitiveÚ
new_headerÚencodeds	            r   r`   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                ó¸  — t                                d|||¦  «         |\  }}|st          nt          }| j                             ||¦  «        }|€7|                      ||||¦  «        }|s| j                             ||¦  «         |S |\  }	}}
|
r|                      |	¦  «        }n5|  	                    |	|||¦  «        }|s| j                             ||¦  «         |S )z6
        Serializes a header key-value tuple.
        z7Adding %s to the header table, sensitive:%s, huffman:%s)
r6   r7   ÚINDEX_INCREMENTALÚINDEX_NEVERrg   ÚsearchÚ_encode_literalr~   Ú_encode_indexedÚ_encode_indexed_literal)rk   r…   r‚   rx   r)   r*   ÚindexbitÚmatchr„   rD   Úperfects              r   r~   zEncoder.add  s  € õ 	�	Š	ØEØØØñ		
ô 	
ð 	
ð ‰ˆˆeð -6ÐFÕ$Ð$½;ˆð Ô!×(Ò(¨¨uÑ5Ô5ˆàˆ=ð ×*Ò*¨4°¸À'ÑJÔJˆGØð 3ØÔ!×%Ò% d¨EÑ2Ô2Ð2ØˆNð
  %Ñˆˆt�Wàð 	3à×*Ò*¨5Ñ1Ô1ˆGˆGð ×2Ò2Ø�u˜h¨ñô ˆGð ð 3ØÔ!×%Ò% d¨EÑ2Ô2Ð2àˆr   rD   c                ó`   — t          |d¦  «        }|dxx         dz  cc<   t          |¦  «        S )zD
        Encodes a header using the indexed representation.
        r5   r   r3   )r>   r&   )rk   rD   Úfields      r   rŒ   zEncoder._encode_indexedM  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.
        r5   r   r3   r   )rh   r`   r>   r}   r   r&   )rk   r)   r*   rŽ   rx   Úname_lenÚ	value_lens          r   r‹   zEncoder._encode_literalU  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   r5   r3   r   )rˆ   r>   Úordrh   r`   r}   r   r&   )rk   rD   r*   rŽ   rx   Úprefixr•   s          r   r�   zEncoder._encode_indexed_literalj  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   é    )ri   r>   r&   )rk   ÚblockÚ
size_bytesÚbs       r   rz   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#   rd   ©r#   r-   ©r*   r-   r#   rd   )T)rv   rw   rx   r"   r#   r&   ©F)r…   r†   r‚   r"   rx   r"   r#   r&   )rD   r-   r#   r&   )
r)   r&   r*   r&   rŽ   r&   rx   r"   r#   r&   )
rD   r-   r*   r&   rŽ   r&   rx   r"   r#   r&   )r#   r&   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rl   Úpropertyrq   Úsetterr`   r~   rŒ   r‹   r�   rz   r   r   r   rc   rc   •   s  € € € € € ðð ð
0ð 0ð 0ð 0ð ð)ð )ð )ñ „Xð)ð Ôð2ð 2ð 2ñ Ôð2ð  $ðkð kð kð kð kðZ/ð /ð /ð /ð /ðbð ð ð ð
ð 
ð 
ð 
ð 
ð*Bð Bð Bð Bð Bð,ð ð ð ð ð r   rc   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#   rd   c                ó\   — t          ¦   «         | _        || _        | j        j        | _        d S rf   )r   rg   r­   rp   Úmax_allowed_table_size)rk   r­   s     r   rl   zDecoder.__init__¤  s.   € Ý'™MœMˆÔð  %9ˆÔ!ð '+Ô&7Ô&?ˆÔ#Ð#Ð#r   c                ó   — | j         j        S rn   ro   rj   s    r   rq   zDecoder.header_table_sizeÀ  rr   r   r*   c                ó   — || j         _        d S rf   ro   ru   s     r   rq   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   r3   é@   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)r6   r7   Ú
memoryviewr}   r"   Ú_decode_indexedÚ_decode_literal_indexr   Ú_update_encoding_contextÚ_decode_literal_no_indexr:   r   r­   r	   Ú_assert_valid_table_sizeÚUnicodeDecodeError)rk   r?   r!   Údata_memrv   Údata_lenÚinflated_sizeÚcurrent_indexÚcurrentÚindexedÚliteral_indexÚencoding_updater    Úconsumedr;   rI   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)rq   r¯   r   )rk   r;   s     r   r¼   z Decoder._assert_valid_table_size  s1   € ð
 Ô! DÔ$?Ò?Ð?ØGˆCÝ'¨Ñ,Ô,Ð,ð @Ð?r   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)rJ   r¯   r   rq   )rk   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.
        r5   zDecoded %s, consumed %d)rJ   r   rg   Úget_by_indexr6   r7   )rk   r?   rD   rÆ   r    s        r   r¸   zDecoder._decode_indexed3  sT   € õ )¨¨qÑ1Ô1‰ˆˆxÝ˜dÔ/×<Ò<¸UÑCÔCÐDˆÝ�	Š	Ð+¨V°XÑ>Ô>Ð>Ø�xÐÐr   c                ó0   — |                       |d¬¦  «        S )NF©Úshould_index©Ú_decode_literal©rk   r?   s     r   r»   z Decoder._decode_literal_no_index<  s   € Ø×#Ò# D°uÐ#Ñ=Ô=Ð=r   c                ó0   — |                       |d¬¦  «        S )NTrÎ   rÐ   rÒ   s     r   r¹   zDecoder._decode_literal_index?  s   € Ø×#Ò# D°tÐ#Ñ<Ô<Ð<r   rÏ   c                óh  — 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   Nr5   zTruncated header blockr3   z/Decoded %s, total consumed %d bytes, indexed %s)r"   rJ   rg   rÌ   r}   r   r   r   r   r~   r6   r7   )rk   r?   rÏ   Útotal_consumedÚindexed_namer”   Únot_indexableÚ	high_byterD   rÆ   r)   Úlengthr;   r*   r    s                  r   rÑ   zDecoder._decode_literalB  s,  € ð ˆð ð 	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#   rd   r¢   r£   r¤   )r?   r&   r!   r"   r#   r²   r¡   )r?   r&   r#   r-   )r?   r&   r#   rÊ   )r?   r&   rÏ   r"   r#   rÊ   )r¥   r¦   r§   r¨   ÚDEFAULT_MAX_HEADER_LIST_SIZErl   r©   rq   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-ð -ð -ð -ð
ð 
ð 
ð 
ð ð  ð  ð  ð>ð >ð >ð >ð=ð =ð =ð =ðL&ð L&ð L&ð L&ð L&ð L&r   r¬   )r    r   r!   r"   r#   r   )r,   r-   r.   r-   r#   r/   )r?   r&   r.   r-   r#   r@   )rK   rL   r#   rM   )r*   r]   r#   r&   )+r¨   Ú
__future__r   ÚloggingÚtypingr   r   Ú
exceptionsr   r   r	   rx   r
   Úhuffman_constantsr   r   Úhuffman_tabler   Ústructr   r   r   Útabler   r   Úcollections.abcr   Ú	getLoggerr¥   r6   Ú
INDEX_NONEr‰   rˆ   Úranger9   rÝ   r+   r>   rJ   r\   rQ   rc   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±´Ð:Ñ:Ô:Ð ð  'Ð ð
)ð 
)ð 
)ð 
)ðð ð ð ð>$ð $ð $ð $ðN$ð $ð $ð $ð&	!ð 	!ð 	!ð 	!ðvð vð vð vð vñ vô vð vðr@&ð @&ð @&ð @&ð @&ñ @&ô @&ð @&ð @&ð @&r   