
     h                     d    d dl Z d dlmZ d dlmZ ddlmZ ddlmZm	Z	 dgZ
 G d de          ZdS )	    N)tsp	to_thread   )TimeStamper)TimestampRequestErrorset_tsp_headersHTTPTimeStamperc                   T     e Zd ZdZd
 fd	ZdefdZdej        dej	        fd	Z
 xZS )r
   z/
    Standard HTTP-based timestamp client.
    F   Nc                     |r$|                     d          st          d          || _        || _        || _        || _        t                                                       dS )ax  
        Initialise the timestamp client.

        :param url:
            URL where the server listens for timestamp requests.
        :param https:
            Enforce HTTPS.
        :param timeout:
            Timeout (in seconds)
        :param auth:
            Value of HTTP ``Authorization`` header
        :param headers:
            Other headers to include.
        zhttps:zTimestamp URL is not HTTPS.N)
startswith
ValueErrorurltimeoutauthheaderssuper__init__)selfr   httpsr   r   r   	__class__s         c/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/pyhanko/sign/timestamps/requests_client.pyr   zHTTPTimeStamper.__init__   sg      	<11 	<:;;;	    returnc                 .    t          | j        pi           S )zc
        Format the HTTP request headers.

        :return:
            Header dictionary.
        )r	   r   )r   s    r   request_headerszHTTPTimeStamper.request_headers'   s     t|1r222r   reqc                 D    K    fd}t          |           d {V }|S )Nc                     	 t          j        j                                                                        j        j                  } n"# t          $ r}t          d          |d }~ww xY w| j	        
                    d          dk    rt          d|           t          j                            | j                  S )N)r   r   r   z,Error in communication with timestamp serverzContent-Typezapplication/timestamp-replyz'Timestamp server response is malformed.)requestspostr   dumpr   r   r   IOErrorr   r   getr   TimeStampResploadcontent)raw_reser   r   s     r   taskz8HTTPTimeStamper.async_request_tsa_response.<locals>.task3   s    "-HHHJJ 0022 L      +B  ##N3301 1 ,=w   $))'/:::s   AA 
A/A**A/r   )r   r   r+   responses   ``  r   async_request_tsa_responsez*HTTPTimeStamper.async_request_tsa_response0   sJ      	; 	; 	; 	; 	; 	;. #4((((((r   )Fr   NN)__name__
__module____qualname____doc__r   dictr   r   TimeStampReqr&   r-   __classcell__)r   s   @r   r
   r
      s              .3 3 3 3 3#		       r   )r!   
asn1cryptor   %pyhanko_certvalidator._asyncio_compatr   apir   common_utilsr   r	   __all__r
    r   r   <module>r;      s           ; ; ; ; ; ;       @ @ @ @ @ @ @ @
@ @ @ @ @k @ @ @ @ @r   