ó
    †>i0
  ã                   ó:   • S r SSKJr  SSKJrJr   " S S\5      rg)zº
requests_toolbelt.source_adapter
================================

This file contains an implementation of the SourceAddressAdapter originally
demonstrated on the Requests GitHub page.
é    )ÚHTTPAdapteré   )ÚpoolmanagerÚ
basestringc                   óB   ^ • \ rS rSrSrU 4S jrSS jrU 4S jrSrU =r	$ )ÚSourceAddressAdapteré   aâ  
A Source Address Adapter for Python Requests that enables you to choose the
local address to bind to. This allows you to send your HTTP requests from a
specific interface and IP address.

Two address formats are accepted. The first is a string: this will set the
local IP address to the address given in the string, and will also choose a
semi-random high port for the local port number.

The second is a two-tuple of the form (ip address, port): for example,
``('10.10.10.10', 8999)``. This will set the local IP address to the first
element, and the local port to the second element. If ``0`` is used as the
port number, a semi-random high port will be selected.

.. warning:: Setting an explicit local port can have negative interactions
             with connection-pooling in Requests: in particular, it risks
             the possibility of getting "Address in use" errors. The
             string-only argument is generally preferred to the tuple-form.

Example usage:

.. code-block:: python

    import requests
    from requests_toolbelt.adapters.source import SourceAddressAdapter

    s = requests.Session()
    s.mount('http://', SourceAddressAdapter('10.10.10.10'))
    s.mount('https://', SourceAddressAdapter(('10.10.10.10', 8999)))
c                 óº   >• [        U[        5      (       a
  US4U l        O'[        U[        5      (       a  Xl        O[	        S5      e[
        [        U ]  " S0 UD6  g )Nr   z<source_address must be IP address string or (ip, port) tuple© )Ú
isinstancer   Úsource_addressÚtupleÚ	TypeErrorÚsuperr   Ú__init__)Úselfr   ÚkwargsÚ	__class__s      €Ú^/home/mande/repo/quber/.venv/lib/python3.13/site-packages/requests_toolbelt/adapters/source.pyr   ÚSourceAddressAdapter.__init__-   sU   ø€ Ü�n¤j×1Ñ1Ø#1°1Ð"5ˆDÕÜ˜¬×.Ñ.Ø"0ÕäØNóð ô 	Ô" DÒ2Ñ<°VÓ<ó    c                 óP   • [         R                  " UUUU R                  S9U l         g )N)Ú	num_poolsÚmaxsizeÚblockr   )r   ÚPoolManagerr   )r   Úconnectionsr   r   s       r   Úinit_poolmanagerÚ%SourceAddressAdapter.init_poolmanager9   s'   € Ü&×2Ò2Ø!ØØØ×.Ñ.ñ	0ˆÕr   c                 óJ   >• U R                   US'   [        [        U ]  " U0 UD6$ )Nr   )r   r   r   Úproxy_manager_for)r   Úargsr   r   s      €r   r!   Ú&SourceAddressAdapter.proxy_manager_for@   s4   ø€ Ø#'×#6Ñ#6ˆÐÑ ÜÔ)¨4ÒBØðØñð 	r   )r   r   )F)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r!   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s   ø† ñõ<
=ô0÷ó r   r   N)r(   Úrequests.adaptersr   Ú_compatr   r   r   r   r   r   Ú<module>r-      s   ðñõ *ç -ô5˜;õ 5r   