From b5e3f736c0c6654c3ef0d1f280a4eacdb5ca91de Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 8 Apr 2020 22:11:52 +0200 Subject: minor improvements, tests++ --- mitmproxy/addons/command_history.py | 6 +++--- mitmproxy/net/http/http1/read.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'mitmproxy') diff --git a/mitmproxy/addons/command_history.py b/mitmproxy/addons/command_history.py index 2c1bf887..d5aaa928 100644 --- a/mitmproxy/addons/command_history.py +++ b/mitmproxy/addons/command_history.py @@ -27,7 +27,7 @@ class CommandHistory: def running(self): # FIXME: We have a weird bug where the contract for configure is not followed and it is never called with # confdir or command_history as updated. - self.configure("command_history") + self.configure("command_history") # pragma: no cover def configure(self, updated): if "command_history" in updated or "confdir" in updated: @@ -36,9 +36,9 @@ class CommandHistory: self.set_filter('') def done(self): - if ctx.options.command_history and len(self.history) > self.VACUUM_SIZE: + if ctx.options.command_history and len(self.history) >= self.VACUUM_SIZE: # vacuum history so that it doesn't grow indefinitely. - history_str = "\n".join(self.history[-self.VACUUM_SIZE / 2:]) + "\n" + history_str = "\n".join(self.history[-self.VACUUM_SIZE // 2:]) + "\n" self.history_file.write_text(history_str) @command.command("commands.history.add") diff --git a/mitmproxy/net/http/http1/read.py b/mitmproxy/net/http/http1/read.py index 0fc03f1b..a9585d7d 100644 --- a/mitmproxy/net/http/http1/read.py +++ b/mitmproxy/net/http/http1/read.py @@ -331,7 +331,8 @@ def _read_headers(rfile): while True: line = rfile.readline() if not line or line == b"\r\n" or line == b"\n": - break + # we do have coverage of this, but coverage.py does not detect it. + break # pragma: no cover if line[0] in b" \t": if not ret: raise exceptions.HttpSyntaxException("Invalid headers") -- cgit v1.2.3