o
    #`^h:                     @   s8   d Z ddlmZmZ G dd deZG dd deZdS )z)linebot.aiohttp_async_http_client module.    )AsyncHttpClientAsyncHttpResponsec                       sN   e Zd ZdZejf fdd	ZdddZdddZdd	d
Z	dddZ
  ZS )AiohttpAsyncHttpClientz#HttpClient implemented by requests.c                    s   t t| | || _dS )a7  __init__ method.

        :param timeout: (optional) How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`DEFAULT_TIMEOUT`
        :type timeout: float | tuple(float, float)
        N)superr   __init__session)selfr   timeout	__class__ _/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/linebot/aiohttp_async_http_client.pyr      s   	
zAiohttpAsyncHttpClient.__init__Nc                    2   |du r| j }| jj||||dI dH }t|S )a&  GET request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param dict params: (optional) Request query parameter
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`AsyncHttpResponse`
        :return: AsyncHttpResponse instance
        N)headersparamsr	   )r	   r   getAiohttpAsyncHttpResponse)r   urlr   r   r	   responser   r   r   r   #   
   zAiohttpAsyncHttpClient.getc                    r   )aQ  POST request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`AiohttpAsyncHttpResponse`
        :return: AiohttpAsyncHttpResponse instance
        Nr   datar	   )r	   r   postr   r   r   r   r   r	   r   r   r   r   r   7   r   zAiohttpAsyncHttpClient.postc                    r   )aS  DELETE request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`AiohttpAsyncHttpResponse`
        :return: AiohttpAsyncHttpResponse instance
        Nr   )r	   r   deleter   r   r   r   r   r   K   r   zAiohttpAsyncHttpClient.deletec                    r   )aP  PUT request.

        :param str url: Request url
        :param dict headers: (optional) Request headers
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        :param timeout: (optional), How long to wait for the server
            to send data before giving up, as a float,
            or a (connect timeout, read timeout) float tuple.
            Default is :py:attr:`self.timeout`
        :type timeout: float | tuple(float, float)
        :rtype: :py:class:`AiohttpAsyncHttpResponse`
        :return: AiohttpAsyncHttpResponse instance
        Nr   )r	   r   putr   r   r   r   r   r   _   r   zAiohttpAsyncHttpClient.put)NNN)__name__
__module____qualname____doc__r   DEFAULT_TIMEOUTr   r   r   r   r   __classcell__r   r   r
   r   r      s    


r   c                   @   s^   e Zd ZdZdd Zedd Zedd Zedd	 Zed
d Z	edd Z
dddZdS )r   z4AsyncHttpResponse implemented by aiohttp's response.c                 C   s
   || _ dS )zF__init__ method.

        :param response: aiohttp's response
        N)r   )r   r   r   r   r   r   w   s   
z!AiohttpAsyncHttpResponse.__init__c                 C      | j jS )zGet status code.)r   statusr   r   r   r   status_code~   s   z$AiohttpAsyncHttpResponse.status_codec                 C   r"   )zTGet headers.

        :rtype :py:class:`aiohttp.multidict.CIMultiDictProxy`
        )r   r   r$   r   r   r   r      s   z AiohttpAsyncHttpResponse.headersc                       | j  I dH S )z"Get response body as text-decoded.N)r   textr$   r   r   r   r'         zAiohttpAsyncHttpResponse.textc                    s   | j j I dH S )zGet response body as binary.N)r   contentreadr$   r   r   r   r)      s   z AiohttpAsyncHttpResponse.contentc                    r&   )z"Get response body as json-decoded.N)r   jsonr$   r   r   r   r+      r(   zAiohttpAsyncHttpResponse.json   c                 C   s   | j j|S )zXGet response body as iterator content (stream).

        :param int chunk_size:
        )r   r)   iter_chunked)r   
chunk_sizer   r   r   iter_content   s   z%AiohttpAsyncHttpResponse.iter_contentN)r,   )r   r   r   r   r   propertyr%   r   r'   r)   r+   r/   r   r   r   r   r   t   s    




r   N)r   linebotr   r   r   r   r   r   r   r   <module>   s   `