o
    Jh                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ eeZdd	 Zd
d Zdd Zdd Zdd Zdd Zdd ZdeiZdS )z
NOTE: All functions in this module are considered private and are
subject to abrupt breaking changes. Please do not use them directly.

    N)GzipFile)compress)	urlencode)register_feature_id)determine_content_lengthc                 C   sr   t | ||r5|jd D ]+}t|}|dur.td| ||d |d< t|d |  dS td| qdS dS )zAAttempt to compress the request body using the modeled encodings.	encodingsNz%Compressing request with %s encoding.bodyheadersz$Unsupported compression encoding: %s)_should_compress_requestrequest_compressionCOMPRESSION_MAPPINGgetloggerdebug_set_compression_header)configrequest_dictoperation_modelencodingencoder r   q/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/botocore/compress.pymaybe_compress_request   s   
r   c           	      C   s   | j dur>| jdkr>|jd ur>t|s#t|d }d}t|| dS |jr1| }|j	}d|vS t
|d }| j}||kS dS )NTv2r   z*Body type %s does not support compression.FrequiresLength)disable_request_compressionsignature_versionr   _is_compressible_typetyper   r   has_streaming_inputget_streaming_inputmetadata_get_body_size"request_min_compression_size_bytes)	r   r   r   	body_typelog_msgstreaming_inputstreaming_metadata	body_sizemin_sizer   r   r   r
   -   s    


r
   c                 C   sL   | d }t |trt|dddd}|| d< t |tttf}|p%t|dS )Nr   Tutf-8)doseqr   read)
isinstancedictr   encodestrbytes	bytearrayhasattr)r   r   is_supported_typer   r   r   r   E   s   
r   c                 C   s$   t | }|d u rtd|  d}|S )NzCUnable to get length of the request body: %s. Skipping compression.r   )r   r   r   )r   sizer   r   r   r"   O   s   r"   c                 C   s~   t d t| trt| dS t| ttfrt| S t| dr=t| dr9t| dr9|  }t	| }| 
| |S t	| S d S )NGZIP_REQUEST_COMPRESSIONr*   r,   seektell)r   r-   r0   gzip_compressr/   r1   r2   r3   r8   _gzip_compress_fileobjr7   )r   current_positioncompressed_objr   r   r   _gzip_compress_body[   s   


r=   c                 C   st   t  }t|dd!}	 | d}|snt|tr|d}|| qW d    n1 s.w   Y  |d |S )Nwb)fileobjmodeTi    r*   r   )	ioBytesIOr   r,   r-   r0   r/   writer7   )r   r<   gzchunkr   r   r   r:   j   s   




r:   c                 C   s4   |  d}|d u r|| d< d S | d| | d< d S )NzContent-Encoding,)r   )r	   r   	ce_headerr   r   r   r   x   s   
r   gzip)__doc__rA   loggingrH   r   r   r9   botocore.compatr   botocore.useragentr   botocore.utilsr   	getLogger__name__r   r   r
   r   r"   r=   r:   r   r   r   r   r   r   <module>   s"   

