scripts.__pycache__.proxy.cpython-37.pyc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mitmproxy-java Show documentation
Show all versions of mitmproxy-java Show documentation
A bridge between Python's mitmproxy and Java programs. Built on top of mitmproxy-node
B
?د\?" ? @ s? d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlmZ ddlm
Z
dd? Zdd? Zd d
? ZG dd? d?Ze? gZdS )
zd
Interception proxy using mitmproxy (https://mitmproxy.org).
Communicates to NodeJS via websockets.
? N)?ctx)?httpc C s t | d d?t | d d?gS )z<
Converts a tuple of strings into a tuple of bytes.
r ?utf8? )?bytes)Zheader_entry? r ?scripts/proxy.py?convert_headers_to_bytes s r c C s | dkrt ? S | S dS )zG
Converts a HTTP request/response body into a list of numbers.
N)r )?bodyr r r ?convert_body_to_bytes s r c C s4 d| kr0| d ? ? }d|kp.d|kp.|?? dkS dS )Nzcontent-type?application?text? T)?lower?strip)?headers?ctr r r ?is_text_response# s r c @ s` e Zd ZdZdd? Zdd? Zdd? Zdd ? Zd
d? Zdd
? Z dd? Z
dd? Zdd? Zdd? Z
dS )?WebSocketAdapterzo
Relays HTTP/HTTPS requests to a websocket server.
Enables using MITMProxy from outside of Python.
c C s t ?? | _| j?| ?? ? dS )zz
Main function of the websocket thread. Runs the websocket event loop
until MITMProxy shuts down.
N)?asyncio?new_event_loopZworker_event_loop?run_until_complete?websocket_loop)?selfr r r ?websocket_thread0 s
z!WebSocketAdapter.websocket_threadc C s6 t ?? | _ tg ?| _d| _d| _tj| jd?? ? d S )NF)?target)
?queue?Queue? frozenset?intercept_paths?only_intercept_text_files?finished? threading?Threadr ?start)r r r r ?__init__8 s
zWebSocketAdapter.__init__c C s&