mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
commit
7fde02ac90
@ -59,9 +59,7 @@ class RequestReplayThread(basethread.BaseThread):
|
||||
# In all modes, we directly connect to the server displayed
|
||||
if self.options.mode.startswith("upstream:"):
|
||||
server_address = server_spec.parse_with_mode(self.options.mode)[1].address
|
||||
server = connections.ServerConnection(
|
||||
server_address, (self.options.listen_host, 0)
|
||||
)
|
||||
server = connections.ServerConnection(server_address)
|
||||
server.connect()
|
||||
if r.scheme == "https":
|
||||
connect_request = http.make_connect_request((r.data.host, r.port))
|
||||
@ -85,10 +83,7 @@ class RequestReplayThread(basethread.BaseThread):
|
||||
r.first_line_format = "absolute"
|
||||
else:
|
||||
server_address = (r.host, r.port)
|
||||
server = connections.ServerConnection(
|
||||
server_address,
|
||||
(self.options.listen_host, 0)
|
||||
)
|
||||
server = connections.ServerConnection(server_address)
|
||||
server.connect()
|
||||
if r.scheme == "https":
|
||||
server.establish_tls(
|
||||
|
@ -236,7 +236,10 @@ class CommandManager(mitmproxy.types._CommandBase):
|
||||
"""
|
||||
Execute a command string. May raise CommandError.
|
||||
"""
|
||||
parts = list(lexer(cmdstr))
|
||||
try:
|
||||
parts = list(lexer(cmdstr))
|
||||
except ValueError as e:
|
||||
raise exceptions.CommandError("Command error: %s" % e)
|
||||
if not len(parts) >= 1:
|
||||
raise exceptions.CommandError("Invalid command: %s" % cmdstr)
|
||||
return self.call_strings(parts[0], parts[1:])
|
||||
|
@ -96,8 +96,8 @@ class Reply:
|
||||
def commit(self):
|
||||
"""
|
||||
Ultimately, messages are committed. This is done either automatically by
|
||||
if the message is not taken or manually by the entity which called
|
||||
.take().
|
||||
the handler if the message is not taken or manually by the entity which
|
||||
called .take().
|
||||
"""
|
||||
if self.state != "taken":
|
||||
raise exceptions.ControlException(
|
||||
|
@ -281,6 +281,8 @@ def test_simple():
|
||||
c.execute("one.two too many args")
|
||||
with pytest.raises(exceptions.CommandError, match="Unknown"):
|
||||
c.call("nonexistent")
|
||||
with pytest.raises(exceptions.CommandError, match="No escaped"):
|
||||
c.execute("\\")
|
||||
|
||||
c.add("empty", a.empty)
|
||||
c.execute("empty")
|
||||
|
Loading…
Reference in New Issue
Block a user