ó
    %Äãg#0  ã                  óà   • S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr   " S
 S\R                   5      rSS jr " S S5      r " S S\\	\\4   \4   5      rSS jrg)a  
h2/settings
~~~~~~~~~~~

This module contains a HTTP/2 settings object. This object provides a simple
API for manipulating HTTP/2 settings, keeping track of both the current active
state of the settings and the unacknowledged future values of the settings.
é    )ÚannotationsN)ÚIteratorÚMutableMapping)ÚUnion)ÚSettingsFrameé   )Ú
ErrorCodes)ÚInvalidSettingsValueErrorc                  óÀ   • \ rS rSrSr\R                  r\R                  r\R                  r\R                  r	\R                  r
\R                  r\R                  rSrg)ÚSettingCodesé   z:
All known HTTP/2 setting codes.

.. versionadded:: 2.6.0
© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚHEADER_TABLE_SIZEÚENABLE_PUSHÚMAX_CONCURRENT_STREAMSÚINITIAL_WINDOW_SIZEÚMAX_FRAME_SIZEÚMAX_HEADER_LIST_SIZEÚENABLE_CONNECT_PROTOCOLÚ__static_attributes__r   ó    Ú-/usr/lib/python3/dist-packages/h2/settings.pyr   r      sg   † ñð &×7Ñ7Ðð  ×+Ñ+€Kð +×AÑAÐð (×;Ñ;Ðð #×1Ñ1€Nð )×=Ñ=Ðð ,×CÑCÓr   r   c                ó>   •  [        U 5      $ ! [         a    U s $ f = f)z³
Given an integer setting code, returns either one of :class:`SettingCodes
<h2.settings.SettingCodes>` or, if not present in the known set of codes,
returns the integer directly.
)r   Ú
ValueError)Úcodes    r   Ú_setting_code_from_intr!   <   s&   € ðÜ˜DÓ!Ð!øÜó ØŠðús   ‚
 �›c                  ó(   • \ rS rSrSS jrSS jrSrg)ÚChangedSettingéH   c                ó(   • Xl         X l        X0l        g ©N©ÚsettingÚoriginal_valueÚ	new_value)Úselfr(   r)   r*   s       r   Ú__init__ÚChangedSetting.__init__J   s   € ð
 Œð -Ôð #�r   c                óX   • SU R                   < SU R                   SU R                   S3$ )NzChangedSetting(setting=z, original_value=z, new_value=Ú)r'   ©r+   s    r   Ú__repr__ÚChangedSetting.__repr__W   s6   € à% d§l¡lÑ%5Ð5FÀt×GZÑGZÐF[Ð[gÐhl×hvÑhvÐgwÐwxÐyð	
r   )r*   r)   r(   N)r(   úSettingCodes | intr)   ú
int | Noner*   ÚintÚreturnÚNone)r6   Ústr)r   r   r   r   r,   r1   r   r   r   r   r#   r#   H   s   † ô#÷
r   r#   c                  ó  • \ rS rSrSrSSS jjrSS jr\SS j5       r\R                  S S j5       r\SS j5       r
\
R                  S S	 j5       r
\SS
 j5       r\R                  S S j5       r\SS j5       r\R                  S S j5       r\SS j5       r\R                  S S j5       r\S!S j5       r\R                  S S j5       r\SS j5       r\R                  S S j5       rS"S jrS#S jrS$S jrS%S jrSS jrS&S jrS&S jrSrg)'ÚSettingsé]   a  
An object that encapsulates HTTP/2 settings state.

HTTP/2 Settings are a complex beast. Each party, remote and local, has its
own settings and a view of the other party's settings. When a settings
frame is emitted by a peer it cannot assume that the new settings values
are in place until the remote peer acknowledges the setting. In principle,
multiple settings changes can be "in flight" at the same time, all with
different values.

This object encapsulates this mess. It provides a dict-like interface to
settings, which return the *current* values of the settings in question.
Additionally, it keeps track of the stack of proposed values: each time an
acknowledgement is sent/received, it updates the current values with the
stack of proposed values. On top of all that, it validates the values to
make sure they're allowed, and raises :class:`InvalidSettingsValueError
<h2.exceptions.InvalidSettingsValueError>` if they are not.

Finally, this object understands what the default values of the HTTP/2
settings are, and sets those defaults appropriately.

.. versionchanged:: 2.2.0
   Added the ``initial_values`` parameter.

.. versionchanged:: 2.5.0
   Added the ``max_header_list_size`` property.

:param client: (optional) Whether these settings should be defaulted for a
    client implementation or a server implementation. Defaults to ``True``.
:type client: ``bool``
:param initial_values: (optional) Any initial values the user would like
    set, rather than RFC 7540's defaults.
:type initial_vales: ``MutableMapping``
Nc                ó`  • [         R                  [        R                  " S/5      [         R                  [        R                  " [        U5      /5      [         R                  [        R                  " S/5      [         R                  [        R                  " S/5      [         R                  [        R                  " S/5      0U l	        Ubb  UR                  5        HM  u  p4[        X45      nU(       a  SU SU 3n[        UUS9e[        R                  " U/5      U R                  U'   MO     g g )Ni   iÿÿ  é @  r   úSetting ú has invalid value ©Ú
error_code)r   r   ÚcollectionsÚdequer   r5   r   r   r   Ú	_settingsÚitemsÚ_validate_settingr
   )r+   ÚclientÚinitial_valuesÚkeyÚvalueÚinvalidÚmsgs          r   r,   ÚSettings.__init__�   sü   € ô ×*Ñ*¬K×,=Ò,=¸t¸fÓ,EÜ×$Ñ$¤k×&7Ò&7¼¸V»¸Ó&FÜ×,Ñ,¬k×.?Ò.?ÀÀÓ.HÜ×'Ñ'¬×):Ò):¸E¸7Ó)CÜ×0Ñ0´+×2CÒ2CÀQÀCÓ2HðL
ˆŒð Ñ%Ø,×2Ñ2Ö4‘
�Ü+¨CÓ7�ÞØ$ S EÐ)<¸U¸GÐD�CÜ3ØØ#*ñð ô '2×&7Ò&7¸¸Ó&@�—‘˜sÓ#ò 5ð &r   c                ó¸   • 0 nU R                   R                  5        H9  u  p#[        U5      S:”  d  M  UR                  5       nUS   n[	        X$U5      X'   M;     U$ )zµ
The settings have been acknowledged, either by the user (remote
settings) or by the remote peer (local settings).

:returns: A dict of {setting: ChangedSetting} that were applied.
r   r   )rD   rE   ÚlenÚpopleftr#   )r+   Úchanged_settingsÚkÚvÚold_settingÚnew_settings         r   ÚacknowledgeÚSettings.acknowledgeš   sa   € ð FHÐð —N‘N×(Ñ(Ö*‰DˆAÜ�1‹v˜�zØŸi™i›k�Ø ™d�Ü&4Ø Kó'Ð Ó#ñ	 +ð  Ðr   c                ó(   • U [         R                     $ )zj
The current value of the :data:`HEADER_TABLE_SIZE
<h2.settings.SettingCodes.HEADER_TABLE_SIZE>` setting.
©r   r   r0   s    r   Úheader_table_sizeÚSettings.header_table_size°   s   € ð ”L×2Ñ2Ñ3Ð3r   c                ó(   • X[         R                  '   g r&   rY   ©r+   rJ   s     r   rZ   r[   ¸   s   € à/4Œ\×+Ñ+Ò,r   c                ó(   • U [         R                     $ )z^
The current value of the :data:`ENABLE_PUSH
<h2.settings.SettingCodes.ENABLE_PUSH>` setting.
©r   r   r0   s    r   Úenable_pushÚSettings.enable_push¼   s   € ð ”L×,Ñ,Ñ-Ð-r   c                ó(   • X[         R                  '   g r&   r_   r]   s     r   r`   ra   Ä   s   € à).Œ\×%Ñ%Ò&r   c                ó(   • U [         R                     $ )zn
The current value of the :data:`INITIAL_WINDOW_SIZE
<h2.settings.SettingCodes.INITIAL_WINDOW_SIZE>` setting.
©r   r   r0   s    r   Úinitial_window_sizeÚSettings.initial_window_sizeÈ   s   € ð ”L×4Ñ4Ñ5Ð5r   c                ó(   • X[         R                  '   g r&   rd   r]   s     r   re   rf   Ð   s   € à16Œ\×-Ñ-Ò.r   c                ó(   • U [         R                     $ )zd
The current value of the :data:`MAX_FRAME_SIZE
<h2.settings.SettingCodes.MAX_FRAME_SIZE>` setting.
©r   r   r0   s    r   Úmax_frame_sizeÚSettings.max_frame_sizeÔ   s   € ð ”L×/Ñ/Ñ0Ð0r   c                ó(   • X[         R                  '   g r&   ri   r]   s     r   rj   rk   Ü   s   € à,1Œ\×(Ñ(Ò)r   c                óB   • U R                  [        R                  S5      $ )zt
The current value of the :data:`MAX_CONCURRENT_STREAMS
<h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS>` setting.
l       )Úgetr   r   r0   s    r   Úmax_concurrent_streamsÚSettings.max_concurrent_streamsà   s   € ð �x‰xœ×;Ñ;¸WÓEÐEr   c                ó(   • X[         R                  '   g r&   )r   r   r]   s     r   ro   rp   è   s   € à49Œ\×0Ñ0Ò1r   c                óB   • U R                  [        R                  S5      $ )z¾
The current value of the :data:`MAX_HEADER_LIST_SIZE
<h2.settings.SettingCodes.MAX_HEADER_LIST_SIZE>` setting. If not set,
returns ``None``, which means unlimited.

.. versionadded:: 2.5.0
N)rn   r   r   r0   s    r   Úmax_header_list_sizeÚSettings.max_header_list_sizeì   s   € ð �x‰xœ×9Ñ9¸4Ó@Ð@r   c                ó(   • X[         R                  '   g r&   )r   r   r]   s     r   rs   rt   ÷   s   € à27Œ\×.Ñ.Ò/r   c                ó(   • U [         R                     $ )zv
The current value of the :data:`ENABLE_CONNECT_PROTOCOL
<h2.settings.SettingCodes.ENABLE_CONNECT_PROTOCOL>` setting.
©r   r   r0   s    r   Úenable_connect_protocolÚ Settings.enable_connect_protocolû   s   € ð ”L×8Ñ8Ñ9Ð9r   c                ó(   • X[         R                  '   g r&   rw   r]   s     r   rx   ry     s   € à5:Œ\×1Ñ1Ò2r   c                ó<   • U R                   U   S   nUc  [        eU$ )Nr   )rD   ÚKeyError)r+   rI   Úvals      r   Ú__getitem__ÚSettings.__getitem__  s&   € Ø�n‰n˜SÑ! !Ñ$ˆð ‰;ÜˆNàˆ
r   c                óø   • [        X5      nU(       a  SU SU 3n[        UUS9e U R                  U   nUR                  U5        g ! [         a(    [        R
                  " S /5      nXPR                  U'    NCf = f)Nr>   r?   r@   )rF   r
   rD   r|   rB   rC   Úappend)r+   rI   rJ   rK   rL   rE   s         r   Ú__setitem__ÚSettings.__setitem__  s…   € Ü# CÓ/ˆÞØ˜S˜EÐ!4°U°GÐ<ˆCÜ+ØØ"ñð ð
	(Ø—N‘N 3Ñ'ˆEð
 	�‰�UÕøô	 ó 	(Ü×%Ò% t fÓ-ˆEØ"'�N‰N˜3Óð	(ús   ¦A Á/A9Á8A9c                ó   • U R                   U	 g r&   ©rD   )r+   rI   s     r   Ú__delitem__ÚSettings.__delitem__#  s   € Ø�N‰N˜3Ñr   c                ó6   • U R                   R                  5       $ r&   )rD   Ú__iter__r0   s    r   r‰   ÚSettings.__iter__&  s   € Ø�~‰~×&Ñ&Ó(Ð(r   c                ó,   • [        U R                  5      $ r&   )rO   rD   r0   s    r   Ú__len__ÚSettings.__len__)  s   € Ü�4—>‘>Ó"Ð"r   c                ój   • [        U[        5      (       a  U R                  UR                  :H  $ [        $ r&   )Ú
isinstancer:   rD   ÚNotImplemented©r+   Úothers     r   Ú__eq__ÚSettings.__eq__,  s(   € Ü�eœX×&Ñ&Ø—>‘> U§_¡_Ñ4Ð4ÜÐr   c                óB   • [        U[        5      (       a  X:X  + $ [        $ r&   )r�   r:   r�   r‘   s     r   Ú__ne__ÚSettings.__ne__1  s   € Ü�eœX×&Ñ&ØÒ$Ð$ÜÐr   r…   )TN)rG   ÚboolrH   zdict[SettingCodes, int] | Noner6   r7   )r6   z(dict[SettingCodes | int, ChangedSetting])r6   r5   )rJ   r5   r6   r7   )r6   r4   )rI   r3   r6   r5   )rI   r3   rJ   r5   r6   r7   )rI   r3   r6   r7   )r6   zIterator[SettingCodes | int])r’   Úobjectr6   r˜   )r   r   r   r   r   r,   rV   ÚpropertyrZ   Úsetterr`   re   rj   ro   rs   rx   r~   r‚   r†   r‰   rŒ   r“   r–   r   r   r   r   r:   r:   ]   s|  † ñ!öFAô2 ð, ó4ó ð4ð ×Ñó5ó ð5ð ó.ó ð.ð ×Ñó/ó ð/ð ó6ó ð6ð ×Ñó7ó  ð7ð ó1ó ð1ð ×Ñó2ó ð2ð óFó ðFð ×"Ñ"ó:ó #ð:ð óAó ðAð × Ñ ó8ó !ð8ð ó:ó ð:ð ×#Ñ#ó;ó $ð;ôôô" ô)ô#ô÷
r   r:   c                ó²  • U [         R                  :X  a'  US;  a  [        R                  $  [        R                  $ U [         R                  :X  a@  SUs=::  a  S::  d"   [        R
                  $   [        R
                  $  [        R                  $ U [         R                  :X  a@  SUs=::  a  S::  d"   [        R                  $   [        R                  $  [        R                  $ U [         R                  :X  a'  US:  a  [        R                  $  [        R                  $ U [         R                  :X  a  US;  a  [        R                  $ [        R                  $ )zŽ
Confirms that a specific setting has a well-formed value. If the setting is
invalid, returns an error code. Otherwise, returns 0 (NO_ERROR).
)r   r   r   iÿÿÿr=   iÿÿÿ )
r   r   r	   ÚPROTOCOL_ERRORr   ÚFLOW_CONTROL_ERRORr   r   r   ÚNO_ERROR)r(   rJ   s     r   rF   rF   7  s8  € ð
 ”,×*Ñ*Ó*Ø˜ÓÜ×,Ñ,Ð,ð ô ×ÑÐð 
”L×4Ñ4Ó	4Ø�EÕ'˜ZÔ'Ü×0Ñ0Ð0ð (Ü×0Ñ0Ð0ð (ô ×ÑÐð 
”L×/Ñ/Ó	/Ø˜Õ) Ô)Ü×,Ñ,Ð,ð *Ü×,Ñ,Ð,ð *ô ×ÑÐð 
”L×5Ñ5Ó	5Ø�1‹9Ü×,Ñ,Ð,ð ô
 ×ÑÐð 
”L×8Ñ8Ó	8¸UÈ&Ó=PÜ×(Ñ(Ð(ä×ÑÐr   )r    r5   r6   r3   )r(   r3   rJ   r5   r6   r	   )r   Ú
__future__r   rB   ÚenumÚcollections.abcr   r   Útypingr   Úhyperframe.framer   Úerrorsr	   Ú
exceptionsr
   ÚIntEnumr   r!   r#   r5   r:   rF   r   r   r   Ú<module>r¨      sn   ðñõ #ã Û ß 4Ý å *å Ý 1ô#D�4—<‘<ô #DôL	÷
ñ 
ô*Wˆ~˜e L°#Ð$5Ñ6¸Ð;Ñ<ô Wõtr   