o
    /h	                     @   sF   d Z dgZddlZddlmZ ddlmZ e Z	dd Z
d	d ZdS )
z"GAE specific URL reading functions_defaultFetcher    N)urlfetch   )errorhandlerc                 C   s$   t j }| |d< | |d jfS )Ncontent-type)emailmessageEmailMessageget_content_typeparams)content_typemsg r   F/var/www/html/myenv/lib/python3.10/site-packages/cssutils/_fetchgae.py_parse_header   s   
r   c              
   C   s   z
t j| t jd}W n! t jy+ } ztjd| d| td W Y d}~dS d}~ww |jdkrAtjd| d|j td dS zt|j	d \}}|d	 }W n t
y]   d
}d}Y nw |dkrotjd| d|td ||jfS )a  
    uses GoogleAppEngine (GAE)
        fetch(url, payload=None, method=GET, headers={}, allow_truncated=False)

    Response
        content
            The body content of the response.
        content_was_truncated
            True if the allow_truncated parameter to fetch() was True and
            the response exceeded the maximum response size. In this case,
            the content attribute contains the truncated response.
        status_code
            The HTTP status code.
        headers
            The HTTP response headers, as a mapping of names to values.

    Exceptions
        exception InvalidURLError()
            The URL of the request was not a valid URL, or it used an
            unsupported method. Only http and https URLs are supported.
        exception DownloadError()
            There was an error retrieving the data.

            This exception is not raised if the server returns an HTTP
            error code: In that case, the response data comes back intact,
            including the error code.

        exception ResponseTooLargeError()
            The response data exceeded the maximum allowed size, and the
            allow_truncated parameter passed to fetch() was False.
    )methodzError opening url=z: )errorN   z: HTTP status r   charsetzapplication/octet-streamztext/cssz&Expected "text/css" mime type for url z but found: )r   fetchGETErrorlogwarnIOErrorstatus_coder   headersKeyErrorr   
ValueErrorcontent)urlremimetyper   encodingr   r   r   r      s4    

)__doc____all__email.messager   google.appengine.apir    r   ErrorHandlerr   r   r   r   r   r   r   <module>   s    