mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Fix disconnect, improve coverage, enable file value specifier.
This commit is contained in:
parent
b71e2f6f2b
commit
2e558b7e9d
@ -5,5 +5,6 @@
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
pathoc hostname get:/foo/bar:h"foo"="bar" get:/wah:b@1m
|
||||
|
||||
|
||||
pathoc --ssl hostname get:/foo/bar:h"foo"="bar" get:/wah:b@1m
|
||||
|
@ -26,7 +26,7 @@ class PathodHandler(tcp.BaseHandler):
|
||||
if path.startswith(self.server.prefix):
|
||||
spec = urllib.unquote(path)[len(self.server.prefix):]
|
||||
try:
|
||||
presp = rparse.parse({}, spec)
|
||||
presp = rparse.parse(self.server.request_settings, spec)
|
||||
except rparse.ParseException, v:
|
||||
presp = rparse.InternalResponse(
|
||||
800,
|
||||
@ -34,8 +34,7 @@ class PathodHandler(tcp.BaseHandler):
|
||||
)
|
||||
ret = presp.serve(self.wfile)
|
||||
if ret["disconnect"]:
|
||||
self.close()
|
||||
|
||||
self.finish()
|
||||
ret["request"] = dict(
|
||||
path = path,
|
||||
method = method,
|
||||
@ -65,6 +64,7 @@ class Pathod(tcp.TCPServer):
|
||||
def __init__(self, addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None):
|
||||
tcp.TCPServer.__init__(self, addr)
|
||||
self.ssloptions = ssloptions
|
||||
self.staticdir = staticdir
|
||||
self.prefix = prefix
|
||||
self.app = app.app
|
||||
self.app.config["pathod"] = self
|
||||
@ -73,7 +73,9 @@ class Pathod(tcp.TCPServer):
|
||||
|
||||
@property
|
||||
def request_settings(self):
|
||||
return {}
|
||||
return dict(
|
||||
staticdir = self.staticdir
|
||||
)
|
||||
|
||||
def handle_connection(self, request, client_address):
|
||||
PathodHandler(request, client_address, self)
|
||||
|
@ -2,8 +2,6 @@ import operator, string, random, mmap, os, time
|
||||
import contrib.pyparsing as pp
|
||||
from netlib import http_status
|
||||
|
||||
TESTING = False
|
||||
|
||||
class ParseException(Exception):
|
||||
def __init__(self, msg, s, col):
|
||||
Exception.__init__(self)
|
||||
|
@ -44,12 +44,28 @@ class TestDaemon:
|
||||
def tearDownAll(self):
|
||||
self.d.shutdown()
|
||||
|
||||
def setUp(self):
|
||||
self.d.clear_log()
|
||||
|
||||
def get(self, spec):
|
||||
return requests.get("http://localhost:%s/p/%s"%(self.d.port, spec))
|
||||
|
||||
def test_info(self):
|
||||
assert tuple(self.d.info()["version"]) == version.IVERSION
|
||||
|
||||
def test_logs(self):
|
||||
rsp = requests.get("http://localhost:%s/p/202"%self.d.port)
|
||||
rsp = self.get("202")
|
||||
assert len(self.d.log()) == 1
|
||||
assert self.d.clear_log()
|
||||
assert len(self.d.log()) == 0
|
||||
|
||||
def test_disconnect(self):
|
||||
rsp = self.get("202:b@100k:d200")
|
||||
assert len(rsp.content) < 200
|
||||
|
||||
def test_parserr(self):
|
||||
rsp = self.get("400:msg,b:")
|
||||
assert rsp.status_code == 800
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user