o
    2wi#                     @   sZ   d dl Zd dlmZ d dlmZ G dd dejZG dd dejZ	G dd	 d	ej
ZdS )
    N)	CookieJar)	useragentc                   @   s   e Zd Zedd ZdS )RequestsRequestc                 C      | j S N)payloadself r
   V/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/geventhttpclient/requests.pybody      zRequestsRequest.bodyN)__name__
__module____qualname__propertyr   r
   r
   r
   r   r      s    r   c                   @   s\   e Zd Ze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 Z
dS )RequestsResponsec                 C   r   r   )_requestr   r
   r
   r   request   r   zRequestsResponse.requestc                 C   s   d| j   ko
dk S   S )Nd     )status_coder   r
   r
   r   ok   s   zRequestsResponse.okc                 C      | j jS r   )	_responsestatus_messager   r
   r
   r   reason      zRequestsResponse.reasonc                 C   r   r   )r   urlr   r
   r
   r   r      r   zRequestsResponse.urlc                 C   s   d| j v o| jtddv S )zTrue if this Response is a well-formed HTTP redirect that could have
        been processed automatically (by :meth:`Session.resolve_redirects`).
        locationi,  i6  )headersr   ranger   r
   r
   r   is_redirect   s   zRequestsResponse.is_redirectc                 C   r   r   )streamr   r
   r
   r   raw%   r   zRequestsResponse.rawc                 C   s2   d| j   krdk rn d S tj| j| j dd S )Nr   iX  )code)r   r   BadStatusCoder   r   r
   r
   r   raise_for_status)   s   z!RequestsResponse.raise_for_statusN)r   r   r   r   r   r   r   r   r"   r$   r'   r
   r
   r
   r   r      s    





r   c                       s   e Zd ZdZeZeZdd Zdd Z	dd Z
dd	d
ZdddZdddZdd Z														dddZ fddZdddZ  ZS )Sessiona  This class mimics and blatantly borrows with all due respect
    from the excellent and rightfully popular Requests API.

    Copyright of the original requests project:

    :copyright: (c) 2012 by Kenneth Reitz.
    :license: Apache2, see LICENSE for more details.
    c                 K       | dd | jd|fi |S )zSends a GET request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        allow_redirectsTGET
setdefaultr   r	   r   kwr
   r
   r   get;      zSession.getc                 K   r)   )zSends a OPTIONS request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        r*   TOPTIONSr,   r.   r
   r
   r   optionsF   r1   zSession.optionsc                 K   r)   )zSends a HEAD request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        r*   FHEADr,   r.   r
   r
   r   headQ   r1   zSession.headNc                 K   s   | j d|f||d|S )a  Sends a POST request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the HTTP Request.
        :param json: (optional) json to send in the body of the HTTP Request.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        POST)datajsonr   )r	   r   r7   r8   r/   r
   r
   r   post\   s   zSession.postc                 K      | j d|fd|i|S )af  Sends a PUT request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the HTTP Request.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        PUTr7   r9   r	   r   r7   r/   r
   r
   r   puti      
zSession.putc                 K   r;   )ah  Sends a PATCH request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the HTTP Request.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        PATCHr7   r9   r=   r
   r
   r   patchu   r?   zSession.patchc                 K   s   | j d|fi |S )zSends a DELETE request. Returns a HTTP Response object.

        :param url: URL for the new a HTTP Request object.
        :param \*\*kw: Optional arguments that ``request`` takes.
        :rtype: CompatResponse
        DELETEr9   r.   r
   r
   r   delete   s   zSession.deleteTc              	   C   s   t |	||d D ]\}}|durt| dq	t ||||d D ]\}}|dur2t| dq#t |d D ]\}}|durIt| dq:|ra|rRtdt|}|du r]i }d	|d
< | j|| |||pld||
rqdndd}|du r||j}|S )a|	  Constructs and sends a HTTP request, returns a HTTP Response object.

        NOTE: Only a subset of these parameters is currently (fully) supported.
        And it's also not

        :param method: method for the new request object.
        :param url: URL for the new request object.
        :param params: (optional) Dictionary or bytes to be sent in the query
            string for the request.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the request.
        :param json: (optional) json to send in the body of the
            HTTP Request.
        :param headers: (optional) Dictionary of HTTP Headers to send with the
            HTTP Request.
        :param cookies: (optional) Dict or CookieJar object to send with the
            HTTP Request.
        :param files: (optional) Dictionary of ``'filename': file-like-objects``
            for multipart encoding upload.
        :param auth: (optional) Auth tuple or callable to enable
            Basic/Digest/Custom HTTP Auth.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param allow_redirects: (optional) Set to True by default.
        :type allow_redirects: bool
        :param proxies: (optional) Dictionary mapping protocol or protocol and
            hostname to the URL of the proxy.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use. Defaults to ``True``. When set to
            ``False``, requests will accept any TLS certificate presented by
            the server, and will ignore hostname mismatches and/or expired
            certificates, which will make your application vulnerable to
            man-in-the-middle (MitM) attacks. Setting verify to ``False``
            may be useful during local development or testing.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        :rtype: CompatResponse
        )timeoutcertverifyNzO can not be set on a per-request basis. Please configure the UserAgent instead.)cookiesauthproxieshooksz0 is currently unsupported as a keyword argument.)rJ   z is not supportedz.Can send either data or json, not both at oncezapplication/jsonzContent-Typer   )methodr    filesr   paramsmax_redirectsF)	dictitems
ValueErrorNotImplementedErrorjsonlibdumpsurlopenuppercontent)r	   rK   r   rM   r7   r    rG   rL   rH   rD   r*   rI   rJ   r#   rF   rE   r8   
param_nameparamresponse_r
   r
   r   r      sN   >


	zSession.requestc                    s4   | dd t j|i | | jst | _dS dS )z
        requests.Session has no arguments at all. Unfortunately, we're relying way more
        on configuring the Session / UserAgent, while requests focuses more on
        configuring the single requests.
        rN      N)r-   super__init__	cookiejarr   )r	   argsr/   	__class__r
   r   r^      s
   zSession.__init__c                 C   s   d S r   r
   )r	   r   r   r
   r
   r   _verify_status   s   zSession._verify_status)NNr   )NNNNNNNTNNNNNN)r   r   r   __doc__r   request_typer   response_typer0   r3   r5   r:   r>   rA   rC   r   r^   rc   __classcell__r
   r
   ra   r   r(   .   s8    	



dr(   )r8   rS   http.cookiejarr   geventhttpclientr   CompatRequestr   CompatResponser   	UserAgentr(   r
   r
   r
   r   <module>   s    !