More accurate description of an HTTP read error, make pyflakes happy.

This commit is contained in:
Aldo Cortesi 2013-02-24 11:08:43 +13:00
parent 7d18535665
commit c6f9a2d74d
6 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import os, ssl, hashlib, socket, time, datetime, tempfile, shutil
import os, ssl, time, datetime, tempfile, shutil
from pyasn1.type import univ, constraint, char, namedtype, tag
from pyasn1.codec.der.decoder import decode
from pyasn1.error import PyAsn1Error

View File

@ -279,7 +279,7 @@ def read_response(rfile, method, body_size_limit):
if line == "\r\n" or line == "\n": # Possible leftover from previous message
line = rfile.readline()
if not line:
raise HttpError(502, "Blank server response.")
raise HttpError(502, "Server disconnect.")
parts = line.strip().split(" ", 2)
if len(parts) == 2: # handle missing message gracefully
parts.append("")

View File

@ -139,7 +139,7 @@ class Reader(_FileLike):
raise NetLibTimeout
except socket.error:
raise NetLibDisconnect
except SSL.SysCallError, v:
except SSL.SysCallError:
raise NetLibDisconnect
self.first_byte_timestamp = self.first_byte_timestamp or time.time()
if not data:
@ -322,7 +322,7 @@ class BaseHandler:
self.connection.shutdown()
else:
self.connection.shutdown(socket.SHUT_RDWR)
except (socket.error, SSL.Error), v:
except (socket.error, SSL.Error):
# Socket probably already closed
pass
self.connection.close()

View File

@ -1,4 +1,4 @@
import cStringIO, urllib, time, sys, traceback
import cStringIO, urllib, time, traceback
import odict
@ -128,13 +128,13 @@ class WSGIAdaptor:
write(i)
if not state["headers_sent"]:
write("")
except Exception, v:
except Exception:
try:
s = traceback.format_exc()
errs.write(s)
self.error_page(soc, state["headers_sent"], s)
except Exception, v: # pragma: no cover
pass # pragma: no cover
except Exception: # pragma: no cover
pass
return errs.getvalue()

View File

@ -222,7 +222,7 @@ def test_read_response():
r = cStringIO.StringIO(data)
return http.read_response(r, method, limit)
tutils.raises("blank server response", tst, "", "GET", None)
tutils.raises("server disconnect", tst, "", "GET", None)
tutils.raises("invalid server response", tst, "foo", "GET", None)
data = """
HTTP/1.1 200 OK

View File

@ -1,4 +1,4 @@
import cStringIO, threading, Queue, time, socket
import cStringIO, Queue, time, socket
from netlib import tcp, certutils, test
import mock
import tutils