ó
    ^Ñ7_£%  ã                   ó€   • S SK Jr  S SKrSSKJr  \R
                  " \5      rS r " S S5      r	S r
\
" 5       \	l        g)	é    )ÚdequeNé   )ÚInvalidTableIndexc                 ó6   • S[        U 5      -   [        U5      -   $ )a7  
Calculates the size of a single entry

This size is mostly irrelevant to us and defined
specifically to accommodate memory management for
lower level implementations. The 32 extra bytes are
considered the "maximum" overhead that would be
required to represent each entry in the table.

See RFC7541 Section 4.1
é    )Úlen)ÚnameÚvalues     Ú-/usr/lib/python3/dist-packages/hpack/table.pyÚtable_entry_sizer      s   € ð ”�D“	‰>œC ›JÑ&Ð&ó    c                   óˆ   • \ rS rSrSrSrSr\" \5      rS r	S r
S rS rS	 r\S
 5       r\R                   S 5       rS rSrg)ÚHeaderTableé   zà
Implements the combined static and dynamic header table

The name and value arguments for all the functions
should ONLY be byte strings (b'') however this is not
strictly enforced in the interface.

See RFC7541 Section 2.3
i   )=)s
   :authorityr   )ó   :methods   GET)r   s   POST)ó   :pathó   /)r   s   /index.html)ó   :schemes   http)r   s   https)ó   :statuss   200)r   s   204)r   s   206)r   s   304)r   s   400)r   s   404)r   s   500)s   accept-charsetr   )s   accept-encodings   gzip, deflate)s   accept-languager   )s   accept-rangesr   )s   acceptr   )s   access-control-allow-originr   )s   ager   )s   allowr   )s   authorizationr   )s   cache-controlr   )s   content-dispositionr   )s   content-encodingr   )s   content-languager   )s   content-lengthr   )s   content-locationr   )s   content-ranger   )s   content-typer   )s   cookier   )s   dater   )s   etagr   )s   expectr   )s   expiresr   )s   fromr   )s   hostr   )s   if-matchr   )s   if-modified-sincer   )s   if-none-matchr   )s   if-ranger   )s   if-unmodified-sincer   )s   last-modifiedr   )s   linkr   )s   locationr   )s   max-forwardsr   )s   proxy-authenticater   )s   proxy-authorizationr   )s   ranger   )s   refererr   )s   refreshr   )s   retry-afterr   )s   serverr   )s
   set-cookier   )s   strict-transport-securityr   )s   transfer-encodingr   )s
   user-agentr   )s   varyr   )s   viar   )s   www-authenticater   c                 óh   • [         R                  U l        SU l        SU l        [        5       U l        g )Nr   F)r   ÚDEFAULT_SIZEÚ_maxsizeÚ_current_sizeÚresizedr   Údynamic_entries©Úselfs    r   Ú__init__ÚHeaderTable.__init__l   s(   € Ü#×0Ñ0ˆŒØˆÔØˆŒÜ$›wˆÕr   c                 óü   • UnUS-  nSU::  ab  U[         R                  :  a  [         R                  U   $ U[         R                  -  nU[        U R                  5      :  a  U R                  U   $ [        SU-  5      e)a.  
Returns the entry specified by index

Note that the table is 1-based ie an index of 0 is
invalid.  This is due to the fact that a zero value
index signals that a completely unindexed header
follows.

The entry will either be from the static table or
the dynamic table depending on the value of index.
r   r   zInvalid table index %d)r   ÚSTATIC_TABLE_LENGTHÚSTATIC_TABLEr   r   r   )r   ÚindexÚoriginal_indexs      r   Úget_by_indexÚHeaderTable.get_by_indexr   s}   € ð ˆØ�‰
ˆØ�‹:Ø”{×6Ñ6Ó6Ü"×/Ñ/°Ñ6Ð6à”[×4Ñ4Ñ4ˆEØ”s˜4×/Ñ/Ó0Ó0Ø×+Ñ+¨EÑ2Ð2äÐ 8¸>Ñ IÓJÐJr   c                 óN   • SU R                   U R                  U R                  4-  $ )NzHeaderTable(%d, %s, %r))r   r   r   r   s    r   Ú__repr__ÚHeaderTable.__repr__Š   s+   € Ø(Ø�M‰MØ�L‰LØ× Ñ ð,
ñ 
ð 	
r   c                 óþ   • [        X5      nX0R                  :”  a"  U R                  R                  5         SU l        gU R                  R                  X45        U =R                  U-  sl        U R                  5         g)zu
Adds a new entry to the table

We reduce the table size if the entry will make the
table size greater than maxsize.
r   N)r   r   r   Úclearr   Ú
appendleftÚ_shrink)r   r	   r
   Úsizes       r   ÚaddÚHeaderTable.add‘   sd   € ô   Ó,ˆØ—-‘-ÓØ× Ñ ×&Ñ&Ô(Ø!"ˆDÕð × Ñ ×+Ñ+¨T¨MÔ:Ø×Ò $Ñ&ÕØ�L‰L�Nr   c                 óD  • Sn[         R                  R                  U5      nU(       a#  US   R                  U5      nUb  XQU4$ US   US4n[         R                  S-   n[	        U R
                  5       H(  u  nu  p‰X�:X  d  M  X’:X  a  Xv-   X‰4s  $ Ub  M!  Xv-   US4nM*     U$ )zñ
Searches the table for the entry specified by name
and value

Returns one of the following:
    - ``None``, no match at all
    - ``(index, name, None)`` for partial matches on name only.
    - ``(index, name, value)`` for perfect matches.
Nr   r   )r   ÚSTATIC_TABLE_MAPPINGÚgetr!   Ú	enumerater   )
r   r	   r
   ÚpartialÚheader_name_search_resultr#   ÚoffsetÚiÚnÚvs
             r   ÚsearchÚHeaderTable.search£   s¶   € ð ˆä$/×$DÑ$D×$HÑ$HÈÓ$NÐ!Þ$Ø-¨aÑ0×4Ñ4°UÓ;ˆEØÑ Ø EÐ)Ð)à4°QÑ7¸¸tÐD�ä×0Ñ0°1Ñ4ˆÜ$ T×%9Ñ%9Ö:‰KˆQ‘�Ø�yØ“:Ø™: qÐ+Ò+Ø“_Ø ™z¨1¨dÐ3’Gñ ;ð ˆr   c                 ó   • U R                   $ )N)r   r   s    r   ÚmaxsizeÚHeaderTable.maxsizeÀ   s   € à�}‰}Ðr   c                 ó  • [        U5      n[        R                  SXR                  5        U R                  nXl        X:g  U l        US::  a"  U R
                  R                  5         SU l        g X!:”  a  U R                  5         g g )Nz#Resizing header table to %d from %dr   )	ÚintÚlogÚdebugr   r   r   r+   r   r-   )r   ÚnewmaxÚoldmaxs      r   r>   r?   Ä   sj   € ä�V“ˆÜ�	‰	Ð7¸ÇÁÔOØ—‘ˆØŒØÑ(ˆŒØ�Q‹;Ø× Ñ ×&Ñ&Ô(Ø!"ˆDÕØ‹_Ø�L‰L�Nð r   c                 óè   • U R                   nXR                  :”  aQ  U R                  R                  5       u  p#U[	        X#5      -  n[
        R                  SX#5        XR                  :”  a  MQ  Xl         g)z5
Shrinks the dynamic table to be at or below maxsize
z%Evicting %s: %s from the header tableN)r   r   r   Úpopr   rB   rC   )r   Úcursizer	   r
   s       r   r-   ÚHeaderTable._shrinkÑ   sb   € ð ×$Ñ$ˆØŸ™Ó%Ø×.Ñ.×2Ñ2Ó4‰KˆDØÔ'¨Ó4Ñ4ˆGÜ�I‰IÐ=¸tÔKð Ÿ™Õ%ð %Õr   )r   r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r"   r   r!   r   r%   r(   r/   r;   Úpropertyr>   Úsetterr-   Ú__static_attributes__© r   r   r   r      sn   † ñð €Lð>€Lñ@ ˜lÓ+Ðò'òKò0
òò$ð: ñó ðð ‡^�^ñ
ó ð
õ	%r   r   c                  óŠ   • 0 n [        [        R                  S5       H"  u  nu  p#U R                  X!0 45      nXS   U'   M$     U $ )zÀ
Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).

static_table_mapping used for hash searching.
r   )r4   r   r"   Ú
setdefault)Ústatic_table_mappingr#   r	   r
   r6   s        r   Ú_build_static_table_mappingrV   Ý   sT   € ð ÐÜ )¬+×*BÑ*BÀAÖ FÑˆ‰}�Ø$8×$CÑ$CÀDÐRTÈ+Ó$VÐ!Ø.3 !Ñ$ UÓ+ñ !Gð  Ðr   )Úcollectionsr   ÚloggingÚ
exceptionsr   Ú	getLoggerrJ   rB   r   r   rV   r2   rR   r   r   Ú<module>r[      sD   ðõ Û å )à×Ò˜Ó!€ò'÷@%ñ @%òF ñ $?Ó#@€Õ  r   