mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
code formatting
This commit is contained in:
parent
64978968f2
commit
6d3b3994e2
@ -23,7 +23,9 @@ from ..models import (
|
||||
|
||||
from .base import Layer, Kill
|
||||
|
||||
|
||||
class _HttpTransmissionLayer(Layer):
|
||||
|
||||
def read_request(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -233,7 +235,7 @@ class HttpLayer(Layer):
|
||||
try:
|
||||
response = make_error_response(code, message)
|
||||
self.send_response(response)
|
||||
except NetlibException, H2Error:
|
||||
except NetlibException as H2Error:
|
||||
pass
|
||||
|
||||
def change_upstream_proxy_server(self, address):
|
||||
|
@ -1,12 +1,6 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
import six
|
||||
import struct
|
||||
import threading
|
||||
import time
|
||||
import Queue
|
||||
|
||||
from netlib import tcp
|
||||
from netlib.http import http1
|
||||
@ -17,6 +11,7 @@ from ..models import HTTPRequest, HTTPResponse
|
||||
|
||||
|
||||
class Http1Layer(_HttpTransmissionLayer):
|
||||
|
||||
def __init__(self, ctx, mode):
|
||||
super(Http1Layer, self).__init__(ctx)
|
||||
self.mode = mode
|
||||
|
@ -1,6 +1,5 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
|
||||
import struct
|
||||
import threading
|
||||
import time
|
||||
import Queue
|
||||
@ -17,9 +16,12 @@ from .base import Layer
|
||||
from .http import _HttpTransmissionLayer, HttpLayer
|
||||
from .. import utils
|
||||
from ..models import HTTPRequest, HTTPResponse
|
||||
from ..exceptions import HttpProtocolException, ProtocolException
|
||||
from ..exceptions import HttpProtocolException
|
||||
from ..exceptions import ProtocolException
|
||||
|
||||
|
||||
class SafeH2Connection(H2Connection):
|
||||
|
||||
def __init__(self, conn, *args, **kwargs):
|
||||
super(SafeH2Connection, self).__init__(*args, **kwargs)
|
||||
self.conn = conn
|
||||
@ -71,7 +73,7 @@ class SafeH2Connection(H2Connection):
|
||||
if is_zombie(self, stream_id):
|
||||
return
|
||||
max_outbound_frame_size = self.max_outbound_frame_size
|
||||
frame_chunk = chunk[position:position+max_outbound_frame_size]
|
||||
frame_chunk = chunk[position:position + max_outbound_frame_size]
|
||||
if self.local_flow_control_window(stream_id) < len(frame_chunk):
|
||||
self.lock.release()
|
||||
time.sleep(0)
|
||||
@ -88,6 +90,7 @@ class SafeH2Connection(H2Connection):
|
||||
|
||||
|
||||
class Http2Layer(Layer):
|
||||
|
||||
def __init__(self, ctx, mode):
|
||||
super(Http2Layer, self).__init__(ctx)
|
||||
self.mode = mode
|
||||
@ -226,6 +229,7 @@ class Http2Layer(Layer):
|
||||
|
||||
|
||||
class Http2SingleStreamLayer(_HttpTransmissionLayer, threading.Thread):
|
||||
|
||||
def __init__(self, ctx, stream_id, request_headers):
|
||||
super(Http2SingleStreamLayer, self).__init__(ctx)
|
||||
self.zombie = None
|
||||
|
@ -174,6 +174,7 @@ def safe_subn(pattern, repl, target, *args, **kwargs):
|
||||
"""
|
||||
return re.subn(str(pattern), str(repl), target, *args, **kwargs)
|
||||
|
||||
|
||||
def http2_read_frame(rfile):
|
||||
field = rfile.peek(3)
|
||||
length = int(field.encode('hex'), 16)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from io import BytesIO
|
||||
from netlib.exceptions import HttpSyntaxException
|
||||
from netlib.http import http1
|
||||
from netlib.tcp import TCPClient
|
||||
|
@ -1,14 +1,10 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
|
||||
import inspect
|
||||
import socket
|
||||
import OpenSSL
|
||||
import pytest
|
||||
import traceback
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
from io import BytesIO
|
||||
|
||||
from libmproxy.proxy.config import ProxyConfig
|
||||
from libmproxy.proxy.server import ProxyServer
|
||||
@ -35,10 +31,12 @@ requires_alpn = pytest.mark.skipif(
|
||||
not OpenSSL._util.lib.Cryptography_HAS_ALPN,
|
||||
reason="requires OpenSSL with ALPN support")
|
||||
|
||||
|
||||
class _Http2ServerBase(netlib_tservers.ServerTestBase):
|
||||
ssl = dict(alpn_select=b'h2')
|
||||
|
||||
class handler(netlib.tcp.BaseHandler):
|
||||
|
||||
def handle(self):
|
||||
h2_conn = h2.connection.H2Connection(client_side=False)
|
||||
|
||||
@ -68,6 +66,7 @@ class _Http2ServerBase(netlib_tservers.ServerTestBase):
|
||||
|
||||
|
||||
class _Http2TestBase(object):
|
||||
|
||||
@classmethod
|
||||
def setup_class(self):
|
||||
self.config = ProxyConfig(**self.get_proxy_config())
|
||||
@ -141,6 +140,7 @@ class _Http2TestBase(object):
|
||||
|
||||
@requires_alpn
|
||||
class TestSimple(_Http2TestBase, _Http2ServerBase):
|
||||
|
||||
@classmethod
|
||||
def setup_class(self):
|
||||
_Http2TestBase.setup_class()
|
||||
@ -262,6 +262,7 @@ class TestWithBodies(_Http2TestBase, _Http2ServerBase):
|
||||
|
||||
@requires_alpn
|
||||
class TestPushPromise(_Http2TestBase, _Http2ServerBase):
|
||||
|
||||
@classmethod
|
||||
def setup_class(self):
|
||||
_Http2TestBase.setup_class()
|
||||
|
Loading…
Reference in New Issue
Block a user