mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
minor fixes
This commit is contained in:
parent
9f26d68f47
commit
1a6e41c200
@ -14,7 +14,7 @@ import six
|
|||||||
|
|
||||||
from netlib import tcp, http, certutils, websockets, socks
|
from netlib import tcp, http, certutils, websockets, socks
|
||||||
from netlib.exceptions import HttpException
|
from netlib.exceptions import HttpException
|
||||||
from netlib.http import http1, http2, ALPN_PROTO_HTTP1
|
from netlib.http import http1, http2
|
||||||
|
|
||||||
import language.http
|
import language.http
|
||||||
import language.websockets
|
import language.websockets
|
||||||
@ -289,7 +289,7 @@ class Pathoc(tcp.TCPClient):
|
|||||||
self.sslinfo = None
|
self.sslinfo = None
|
||||||
if self.ssl:
|
if self.ssl:
|
||||||
try:
|
try:
|
||||||
alpn_protos = [ALPN_PROTO_HTTP1]
|
alpn_protos = [http.ALPN_PROTO_HTTP1]
|
||||||
if self.use_http2:
|
if self.use_http2:
|
||||||
alpn_protos.append(http.ALPN_PROTO_H2)
|
alpn_protos.append(http.ALPN_PROTO_H2)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import threading
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from netlib import tcp, http, certutils, websockets
|
from netlib import tcp, http, certutils, websockets
|
||||||
from netlib.exceptions import HttpException
|
from netlib.exceptions import HttpException, HttpReadDisconnect
|
||||||
from netlib.http import ALPN_PROTO_HTTP1, ALPN_PROTO_H2
|
from netlib.http import ALPN_PROTO_HTTP1, ALPN_PROTO_H2
|
||||||
|
|
||||||
from . import version, app, language, utils, log, protocols
|
from . import version, app, language, utils, log, protocols
|
||||||
@ -126,14 +126,13 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
with logger.ctx() as lg:
|
with logger.ctx() as lg:
|
||||||
try:
|
try:
|
||||||
req = self.protocol.read_request(self.rfile)
|
req = self.protocol.read_request(self.rfile)
|
||||||
|
except HttpReadDisconnect:
|
||||||
|
return None, None
|
||||||
except HttpException as s:
|
except HttpException as s:
|
||||||
s = str(s)
|
s = str(s)
|
||||||
lg(s)
|
lg(s)
|
||||||
return None, dict(type="error", msg=s)
|
return None, dict(type="error", msg=s)
|
||||||
|
|
||||||
if req.method == b"" and req.form_in == "":
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
if req.method == 'CONNECT':
|
if req.method == 'CONNECT':
|
||||||
return self.protocol.handle_http_connect([req.host, req.port, req.httpversion], lg)
|
return self.protocol.handle_http_connect([req.host, req.port, req.httpversion], lg)
|
||||||
|
|
||||||
|
@ -68,8 +68,4 @@ class HTTPProtocol(object):
|
|||||||
return self.pathod_handler.handle_http_request, None
|
return self.pathod_handler.handle_http_request, None
|
||||||
|
|
||||||
def read_request(self, lg=None):
|
def read_request(self, lg=None):
|
||||||
try:
|
return http1.read_request(self.pathod_handler.rfile)
|
||||||
return http1.read_request(self.pathod_handler.rfile)
|
|
||||||
except HttpReadDisconnect:
|
|
||||||
# TODO: This is
|
|
||||||
return Request("", b"", b"", b"", b"", b"", b"", None, b"")
|
|
||||||
|
@ -5,7 +5,7 @@ class HTTP2Protocol:
|
|||||||
|
|
||||||
def __init__(self, pathod_handler):
|
def __init__(self, pathod_handler):
|
||||||
self.pathod_handler = pathod_handler
|
self.pathod_handler = pathod_handler
|
||||||
self.wire_protocol = http2.connections.HTTP2Protocol(
|
self.wire_protocol = http2.HTTP2Protocol(
|
||||||
self.pathod_handler, is_server=True, dump_frames=self.pathod_handler.http2_framedump
|
self.pathod_handler, is_server=True, dump_frames=self.pathod_handler.http2_framedump
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class DaemonTests(object):
|
|||||||
def getpath(self, path, params=None):
|
def getpath(self, path, params=None):
|
||||||
scheme = "https" if self.ssl else "http"
|
scheme = "https" if self.ssl else "http"
|
||||||
resp = requests.get(
|
resp = requests.get(
|
||||||
"%s://127.0.0.1:%s/%s" % (
|
"%s://localhost:%s/%s" % (
|
||||||
scheme,
|
scheme,
|
||||||
self.d.port,
|
self.d.port,
|
||||||
path
|
path
|
||||||
|
Loading…
Reference in New Issue
Block a user