o
    ôæh	
  ã                	   @   sr   d Z ddlmZmZ ddlZdgZG dd„ deƒZ			ddeeef dB dej	dB d	ej
dB d
ejfdd„ZdS )z@Utilities for creating standardized httpx AsyncClient instances.é    )ÚAnyÚProtocolNÚcreate_mcp_http_clientc                	   @   sH   e Zd Z			ddeeef dB dejdB dejdB dejfdd„Z	dS )	ÚMcpHttpClientFactoryNÚheadersÚtimeoutÚauthÚreturnc                 C   s   d S )N© )Úselfr   r   r   r
   r
   úX/var/www/html/openai_agents/venv/lib/python3.10/site-packages/mcp/shared/_httpx_utils.pyÚ__call__   s   zMcpHttpClientFactory.__call__©NNN)
Ú__name__Ú
__module__Ú__qualname__ÚdictÚstrÚhttpxÚTimeoutÚAuthÚAsyncClientr   r
   r
   r
   r   r   
   s    üþýüûr   r   r   r   r	   c                 C   sX   ddi}|du rt  d¡|d< n||d< | dur| |d< |dur$||d< t jdi |¤ŽS )	a	  Create a standardized httpx AsyncClient with MCP defaults.

    This function provides common defaults used throughout the MCP codebase:
    - follow_redirects=True (always enabled)
    - Default timeout of 30 seconds if not specified

    Args:
        headers: Optional headers to include with all requests.
        timeout: Request timeout as httpx.Timeout object.
            Defaults to 30 seconds if not specified.
        auth: Optional authentication handler.

    Returns:
        Configured httpx.AsyncClient instance with MCP defaults.

    Note:
        The returned AsyncClient must be used as a context manager to ensure
        proper cleanup of connections.

    Examples:
        # Basic usage with MCP defaults
        async with create_mcp_http_client() as client:
            response = await client.get("https://api.example.com")

        # With custom headers
        headers = {"Authorization": "Bearer token"}
        async with create_mcp_http_client(headers) as client:
            response = await client.get("/endpoint")

        # With both custom headers and timeout
        timeout = httpx.Timeout(60.0, read=300.0)
        async with create_mcp_http_client(headers, timeout) as client:
            response = await client.get("/long-request")

        # With authentication
        from httpx import BasicAuth
        auth = BasicAuth(username="user", password="pass")
        async with create_mcp_http_client(headers, timeout, auth) as client:
            response = await client.get("/protected-endpoint")
    Úfollow_redirectsTNg      >@r   r   r   r
   )r   r   r   )r   r   r   Úkwargsr
   r
   r   r      s   /ÿr   )Ú__doc__Útypingr   r   r   Ú__all__r   r   r   r   r   r   r   r
   r
   r
   r   Ú<module>   s"    
ýÿþýü