From a635e04fbfb1623db25687bb04c022b32bd0ed2c Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 19 Feb 2016 12:16:55 +1300 Subject: console: slightly less hacky hack show http2 warning after first tick --- mitmproxy/console/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mitmproxy/console/__init__.py b/mitmproxy/console/__init__.py index c6b91e16..f7e7b0d5 100644 --- a/mitmproxy/console/__init__.py +++ b/mitmproxy/console/__init__.py @@ -454,13 +454,6 @@ class ConsoleMaster(flow.FlowMaster): signals.update_settings.send() self.loop.set_alarm_in(0.01, self.ticker) - if not hasattr(self, 'http2_error_shown') and self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover - self.http2_error_shown = True - signals.status_message.send( - message="ALPN support missing (OpenSSL 1.0.2+ required). " - "HTTP/2 is disabled. Use --no-http2 to silence this warning.", - expire=5 - ) def run(self): self.ui = urwid.raw_display.Screen() @@ -491,6 +484,14 @@ class ConsoleMaster(flow.FlowMaster): sys.exit(1) self.loop.set_alarm_in(0.01, self.ticker) + if self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover + def http2err(*args, **kwargs): + signals.status_message.send( + message = "HTTP/2 disabled - OpenSSL 1.0.2+ required." + " Use --no-http2 to silence this warning.", + expire=5 + ) + self.loop.set_alarm_in(0.01, http2err) # It's not clear why we need to handle this explicitly - without this, # mitmproxy hangs on keyboard interrupt. Remove if we ever figure it -- cgit v1.2.3