From cd955d3603c1859e09b9ee844cc66909ca6c997a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 29 Sep 2012 10:17:06 -0500 Subject: [PATCH] fixed issue 1046, thanks Houdini --- VERSION | 2 +- gluon/main.py | 16 +++++++++++----- gluon/rocket.py | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 822b46bc..7132c165 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.9 (2012-09-29 09:55:50) dev +Version 2.0.9 (2012-09-29 10:16:59) dev diff --git a/gluon/main.py b/gluon/main.py index 00cb9fd8..459ccf89 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -153,7 +153,10 @@ def copystream_progress(request, chunk_size= 10**5): if not env.content_length: return cStringIO.StringIO() source = env.wsgi_input - size = int(env.content_length) + try: + size = int(env.content_length) + except ValueError: + raise HTTP(400,"Invalid Content-Length header") dest = tempfile.TemporaryFile() if not 'X-Progress-ID' in request.vars: copystream(source, dest, size, chunk_size) @@ -424,13 +427,16 @@ def wsgibase(environ, responder): local_hosts = [http_host,'::1','127.0.0.1', '::ffff:127.0.0.1'] if not global_settings.web2py_runtime_gae: - local_hosts.append(socket.gethostname()) + try: + local_hosts.append(socket.gethostname()) + except TypeError: + pass try: local_hosts.append( - socket.gethostbyname(http_host)) - except socket.gaierror: + socket.gethostbyname(http_host)) + except (socket.gaierror,TypeError): pass - client = get_client(env) + client = get_client(env) x_req_with = str(env.http_x_requested_with).lower() request.update( diff --git a/gluon/rocket.py b/gluon/rocket.py index 43284a21..0e44514b 100644 --- a/gluon/rocket.py +++ b/gluon/rocket.py @@ -1468,7 +1468,7 @@ class Worker(Thread): except UnicodeDecodeError: self.err_log.warning('Client sent invalid header: ' + repr(l)) - if l == '\r\n': + if l.strip() == '': break if l[0] in ' \t' and lname: