a
    fi                     @   s@   d dl Z ddlmZmZ dZG dd deZG dd deZdS )	    N   )
ConnectionPacketCodeci  c                   @   s$   e Zd ZdZdZdd Zdd ZdS )HttpPacketCodecNc                 C   s$   d | jj| jjt|d| S )NzPOST /api HTTP/1.1
Host: {}:{}
Content-Type: application/x-www-form-urlencoded
Connection: keep-alive
Keep-Alive: timeout=100000, max=10000000
Content-Length: {}

ascii)formatZ_conn_ip_portlenencode)selfdata r   U/home/ec2-user/.local/lib/python3.9/site-packages/telethon/network/connection/http.pyencode_packet   s    zHttpPacketCodec.encode_packetc                    sn   |  I d H }|r|d dkr*t|d | dr |dI d H  t|dd }||I d H S q d S )N   
s   content-length:       )readlineasyncioIncompleteReadErrorlower
startswithreadexactlyint)r   readerlinelengthr   r   r   read_packet   s    zHttpPacketCodec.read_packet)__name__
__module____qualname__tagZobfuscate_tagr   r    r   r   r   r   r   	   s   
r   c                       s"   e Zd ZeZd fdd	Z  ZS )ConnectionHttpNc                    s    t  j|| jtkdI d H  d S )N)timeoutssl)superconnectr	   SSL_PORT)r   r&   r'   	__class__r   r   r)   &   s    zConnectionHttp.connect)NN)r!   r"   r#   r   Zpacket_codecr)   __classcell__r   r   r+   r   r%   #   s   r%   )r   
connectionr   r   r*   r   r%   r   r   r   r   <module>   s   