Rename HTTP{In,Out}putException to HTTP{In,Out}putError.

This follows the standard python naming convention for exceptions.
This commit is contained in:
Ben Darnell 2014-06-15 23:39:00 -04:00
parent 66b06d7cf3
commit a0fe934435
4 changed files with 15 additions and 15 deletions

View File

@ -473,7 +473,7 @@ def _curl_header_callback(headers, header_line):
try:
(__, __, reason) = httputil.parse_response_start_line(header_line)
header_line = "X-Http-Reason: %s" % reason
except httputil.HTTPInputException:
except httputil.HTTPInputError:
return
if not header_line:
return

View File

@ -231,7 +231,7 @@ class HTTP1Connection(httputil.HTTPConnection):
self.close()
if self.stream is None:
raise gen.Return(False)
except httputil.HTTPInputException as e:
except httputil.HTTPInputError as e:
gen_log.info("Malformed HTTP message from %s: %s",
self.context, e)
self.close()
@ -377,7 +377,7 @@ class HTTP1Connection(httputil.HTTPConnection):
if self._expected_content_remaining < 0:
# Close the stream now to stop further framing errors.
self.stream.close()
raise httputil.HTTPOutputException(
raise httputil.HTTPOutputError(
"Tried to write more data than Content-Length")
if self._chunking_output and chunk:
# Don't write out empty chunks because that means END-OF-STREAM
@ -412,7 +412,7 @@ class HTTP1Connection(httputil.HTTPConnection):
self._expected_content_remaining != 0 and
not self.stream.closed()):
self.stream.close()
raise httputil.HTTPOutputException(
raise httputil.HTTPOutputError(
"Tried to write %d bytes less than Content-Length" %
self._expected_content_remaining)
if self._chunking_output:
@ -477,8 +477,8 @@ class HTTP1Connection(httputil.HTTPConnection):
headers = httputil.HTTPHeaders.parse(data[eol:])
except ValueError:
# probably form split() if there was no ':' in the line
raise httputil.HTTPInputException("Malformed HTTP headers: %r" %
data[eol:100])
raise httputil.HTTPInputError("Malformed HTTP headers: %r" %
data[eol:100])
return start_line, headers
def _read_body(self, headers, delegate):
@ -486,7 +486,7 @@ class HTTP1Connection(httputil.HTTPConnection):
if content_length:
content_length = int(content_length)
if content_length > self._max_body_size:
raise httputil.HTTPInputException("Content-Length too long")
raise httputil.HTTPInputError("Content-Length too long")
return self._read_fixed_body(content_length, delegate)
if headers.get("Transfer-Encoding") == "chunked":
return self._read_chunked_body(delegate)
@ -515,7 +515,7 @@ class HTTP1Connection(httputil.HTTPConnection):
return
total_size += chunk_len
if total_size > self._max_body_size:
raise httputil.HTTPInputException("chunked body too large")
raise httputil.HTTPInputError("chunked body too large")
bytes_to_read = chunk_len
while bytes_to_read:
chunk = yield self.stream.read_bytes(

View File

@ -445,7 +445,7 @@ class HTTPServerRequest(object):
self.__class__.__name__, args, dict(self.headers))
class HTTPInputException(Exception):
class HTTPInputError(Exception):
"""Exception class for malformed HTTP requests or responses
from remote sources.
@ -454,7 +454,7 @@ class HTTPInputException(Exception):
pass
class HTTPOutputException(Exception):
class HTTPOutputError(Exception):
"""Exception class for errors in HTTP output.
.. versionadded:: 4.0
@ -774,9 +774,9 @@ def parse_request_start_line(line):
try:
method, path, version = line.split(" ")
except ValueError:
raise HTTPInputException("Malformed HTTP request line")
raise HTTPInputError("Malformed HTTP request line")
if not version.startswith("HTTP/"):
raise HTTPInputException(
raise HTTPInputError(
"Malformed HTTP version in HTTP Request-Line: %r" % version)
return RequestStartLine(method, path, version)
@ -796,7 +796,7 @@ def parse_response_start_line(line):
line = native_str(line)
match = re.match("(HTTP/1.[01]) ([0-9]+) ([^\r]*)", line)
if not match:
raise HTTPInputException("Error parsing response start line")
raise HTTPInputError("Error parsing response start line")
return ResponseStartLine(match.group(1), int(match.group(2)),
match.group(3))

View File

@ -126,7 +126,7 @@ class _WSGIConnection(httputil.HTTPConnection):
if self._expected_content_remaining is not None:
self._expected_content_remaining -= len(chunk)
if self._expected_content_remaining < 0:
self._error = httputil.HTTPOutputException(
self._error = httputil.HTTPOutputError(
"Tried to write more data than Content-Length")
raise self._error
self._write_buffer.append(chunk)
@ -137,7 +137,7 @@ class _WSGIConnection(httputil.HTTPConnection):
def finish(self):
if (self._expected_content_remaining is not None and
self._expected_content_remaining != 0):
self._error = httputil.HTTPOutputException(
self._error = httputil.HTTPOutputError(
"Tried to write %d bytes less than Content-Length" %
self._expected_content_remaining)
raise self._error