aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/protocol/http.py4
-rw-r--r--libmproxy/protocol/http1.py7
-rw-r--r--libmproxy/protocol/http2.py10
-rw-r--r--libmproxy/utils.py1
4 files changed, 12 insertions, 10 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index ee9d2d46..6a669ae1 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -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):
diff --git a/libmproxy/protocol/http1.py b/libmproxy/protocol/http1.py
index 0d6095df..fc2cf07a 100644
--- a/libmproxy/protocol/http1.py
+++ b/libmproxy/protocol/http1.py
@@ -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
diff --git a/libmproxy/protocol/http2.py b/libmproxy/protocol/http2.py
index 423c5caa..5c4586de 100644
--- a/libmproxy/protocol/http2.py
+++ b/libmproxy/protocol/http2.py
@@ -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
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index 299e8749..5b1c41f1 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -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)