From fdbb3b76cf8cd7caaa644dc31e48521096ed5349 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Mon, 8 Jun 2015 16:54:19 +0200 Subject: http2: add warning if raw data looks like HTTP/1 --- netlib/http2/frame.py | 4 ++++ netlib/tcp.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'netlib') diff --git a/netlib/http2/frame.py b/netlib/http2/frame.py index ac9b8d50..4a305d82 100644 --- a/netlib/http2/frame.py +++ b/netlib/http2/frame.py @@ -1,3 +1,4 @@ +import sys import struct from functools import reduce from hpack.hpack import Encoder, Decoder @@ -79,6 +80,9 @@ class Frame(object): flags = fields[3] stream_id = fields[4] + if raw_header[:4] == b'HTTP': # pragma no cover + print >> sys.stderr, "WARNING: This looks like an HTTP/1 connection!" + self._check_frame_size(length, state) payload = fp.safe_read(length) diff --git a/netlib/tcp.py b/netlib/tcp.py index 09c43ffc..62545244 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -501,7 +501,7 @@ class TCPClient(_Connection): def get_alpn_proto_negotiated(self): if OpenSSL._util.lib.Cryptography_HAS_ALPN: return self.connection.get_alpn_proto_negotiated() - else: + else: # pragma no cover return None -- cgit v1.2.3