관리-도구
편집 파일: twisted.cpython-37.pyc
B ��Y � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ y0ddl m Z mZmZm Z mZ ddlmZ dZW n ek r| d ZY nX G d d� dee�ZdS ) z� raven.transport.twisted ~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. � )�absolute_import)�BytesIO)�AsyncTransport)� HTTPTransport)�Agent�FileBodyProducer�HTTPConnectionPool�ResponseNeverReceived�readBody)�HeadersTFc s, e Zd ZddgZ� fdd�Zdd� Z� ZS )�TwistedHTTPTransportztwisted+httpz twisted+httpsc s@ t std��tt| �j||� ddlm} t|t|�d�| _ d S )Nz*TwistedHTTPTransport requires twisted.web.r )�reactor)�pool) �has_twisted�ImportError�superr �__init__Ztwisted.internetr r r �_agent)�self�args�kwargsr )� __class__� �H/opt/alt/python37/lib/python3.7/site-packages/raven/transport/twisted.pyr s zTwistedHTTPTransport.__init__c s` | j jd|tt|��ttdd� |�� D ���d�}� fdd�}� �fdd�}|�|��|� d S ) Ns POSTc s s | ]\}}||gfV qd S )Nr )�.0�k�vr r r � <genexpr>- s z2TwistedHTTPTransport.async_send.<locals>.<genexpr>)ZbodyProducer�headersc s4 | � t�}|r&� dd� | jjD �� n � | j� d S )Nc S s g | ] }|j �qS r )�value)r �fr r r � <listcomp>4 s zGTwistedHTTPTransport.async_send.<locals>.on_failure.<locals>.<listcomp>)�checkr r Zreasons)Zfailure�ex)� failure_cbr r � on_failure0 s z3TwistedHTTPTransport.async_send.<locals>.on_failurec s2 � j dkr�� n�� fdd�}t� ��|�S dS )z� Success only means that the request succeeded, *not* that the actual submission was successful. �� c s � t �j�j| �� d S )N)� Exception�code�phrase)�body)r$ �responser r � on_error_body@ s zJTwistedHTTPTransport.async_send.<locals>.on_success.<locals>.on_error_bodyN)r( r �addCallback)r+ r, )r$ � success_cb)r+ r � on_success8 s z3TwistedHTTPTransport.async_send.<locals>.on_success) r Zrequestr r r �dict�itemsr- Z addErrback) r �url�datar r. r$ �dr% r/ r )r$ r. r � async_send) s zTwistedHTTPTransport.async_send)�__name__� __module__�__qualname__�schemer r5 � __classcell__r r )r r r s r N)�__doc__� __future__r Zraven.utils.compatr Zraven.transport.baser Zraven.transport.httpr Ztwisted.web.clientr r r r r Ztwisted.web.http_headersr r r r r r r r �<module> s