From d1319db4c574412f3b3d117e63520afd6f0c2c91 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Sat, 4 Jun 2016 18:22:30 +0200 Subject: [PATCH] fix bug in http transport --- pupy/network/base.py | 3 --- pupy/network/streams/PupySocketStream.py | 2 +- pupy/network/transports/http.py | 4 +++- pupy/pp.py | 2 -- pupy/pupylib/PupyServer.py | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pupy/network/base.py b/pupy/network/base.py index 58e0a204..eb9a205a 100644 --- a/pupy/network/base.py +++ b/pupy/network/base.py @@ -109,9 +109,6 @@ class TransportWrapper(BasePupyTransport): #downstream chaining : self.insts[0].downstream=self.downstream self.insts[0].circuit.downstream=self.downstream - #overloading len of buffer with the max of all chained buff - #self.upstream.overload_len = (lambda s:max([len(x.upstream.buffer) for x in self.insts])) - #self.downstream.overload_len = (lambda s:max([len(x.downstream.buffer) for x in self.insts])) def on_connect(self): for ins in self.insts: diff --git a/pupy/network/streams/PupySocketStream.py b/pupy/network/streams/PupySocketStream.py index b33c1e40..3cabdcce 100644 --- a/pupy/network/streams/PupySocketStream.py +++ b/pupy/network/streams/PupySocketStream.py @@ -44,7 +44,7 @@ class PupySocketStream(SocketStream): def on_connect(self): self.transport.on_connect() - #super(PupySocketStream, self).write(self.downstream.read()) + super(PupySocketStream, self).write(self.downstream.read()) def _read(self): try: diff --git a/pupy/network/transports/http.py b/pupy/network/transports/http.py index 8b969830..2789f648 100644 --- a/pupy/network/transports/http.py +++ b/pupy/network/transports/http.py @@ -26,6 +26,8 @@ def http_req2data(s): if not s.startswith("GET "): raise InvalidHTTPReq() first_line=s.split("\r\n")[0] + if not first_line.endswith(" HTTP/1.1"): + raise InvalidHTTPReq() method, path, http_ver=first_line.split() try: decoded_data=base64.b64decode(path[1:]) @@ -101,7 +103,7 @@ class PupyHTTPClient(PupyHTTPTransport): if name=="Content-Length": content_length=int(value) break - if content_length is None: + if content_length is None or len(rest)