U
    h                     @   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   D/tmp/pip-unpacked-wheel-c81u5j2r/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asyncioZIncompleteReadErrorlower
startswithZ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   