mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-03 12:23:46 +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.exceptions import HttpException
|
||||
from netlib.http import http1, http2, ALPN_PROTO_HTTP1
|
||||
from netlib.http import http1, http2
|
||||
|
||||
import language.http
|
||||
import language.websockets
|
||||
@ -289,7 +289,7 @@ class Pathoc(tcp.TCPClient):
|
||||
self.sslinfo = None
|
||||
if self.ssl:
|
||||
try:
|
||||
alpn_protos = [ALPN_PROTO_HTTP1]
|
||||
alpn_protos = [http.ALPN_PROTO_HTTP1]
|
||||
if self.use_http2:
|
||||
alpn_protos.append(http.ALPN_PROTO_H2)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import threading
|
||||
import urllib
|
||||
|
||||
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 . import version, app, language, utils, log, protocols
|
||||
@ -126,14 +126,13 @@ class PathodHandler(tcp.BaseHandler):
|
||||
with logger.ctx() as lg:
|
||||
try:
|
||||
req = self.protocol.read_request(self.rfile)
|
||||
except HttpReadDisconnect:
|
||||
return None, None
|
||||
except HttpException as s:
|
||||
s = str(s)
|
||||
lg(s)
|
||||
return None, dict(type="error", msg=s)
|
||||
|
||||
if req.method == b"" and req.form_in == "":
|
||||
return None, None
|
||||
|
||||
if req.method == 'CONNECT':
|
||||
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
|
||||
|
||||
def read_request(self, lg=None):
|
||||
try:
|
||||
return http1.read_request(self.pathod_handler.rfile)
|
||||
except HttpReadDisconnect:
|
||||
# TODO: This is
|
||||
return Request("", b"", b"", b"", b"", b"", b"", None, b"")
|
||||
return http1.read_request(self.pathod_handler.rfile)
|
||||
|
@ -5,7 +5,7 @@ class HTTP2Protocol:
|
||||
|
||||
def __init__(self, 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
|
||||
)
|
||||
|
||||
|
@ -63,7 +63,7 @@ class DaemonTests(object):
|
||||
def getpath(self, path, params=None):
|
||||
scheme = "https" if self.ssl else "http"
|
||||
resp = requests.get(
|
||||
"%s://127.0.0.1:%s/%s" % (
|
||||
"%s://localhost:%s/%s" % (
|
||||
scheme,
|
||||
self.d.port,
|
||||
path
|
||||
|
Loading…
Reference in New Issue
Block a user