aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http
diff options
context:
space:
mode:
Diffstat (limited to 'netlib/http')
-rw-r--r--netlib/http/cookies.py1
-rw-r--r--netlib/http/message.py10
-rw-r--r--netlib/http/request.py12
-rw-r--r--netlib/http/response.py14
4 files changed, 16 insertions, 21 deletions
diff --git a/netlib/http/cookies.py b/netlib/http/cookies.py
index 78b03a83..18544b5e 100644
--- a/netlib/http/cookies.py
+++ b/netlib/http/cookies.py
@@ -58,6 +58,7 @@ def _read_quoted_string(s, start):
escaping = False
ret = []
# Skip the first quote
+ i = start # initialize in case the loop doesn't run.
for i in range(start + 1, len(s)):
if escaping:
ret.append(s[i])
diff --git a/netlib/http/message.py b/netlib/http/message.py
index 7cb18f52..e4e799ca 100644
--- a/netlib/http/message.py
+++ b/netlib/http/message.py
@@ -18,6 +18,16 @@ else:
_always_bytes = lambda x: utils.always_bytes(x, "utf-8", "surrogateescape")
+class MessageData(object):
+ def __eq__(self, other):
+ if isinstance(other, MessageData):
+ return self.__dict__ == other.__dict__
+ return False
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+
class Message(object):
def __init__(self, data):
self.data = data
diff --git a/netlib/http/request.py b/netlib/http/request.py
index 325c0080..095b5945 100644
--- a/netlib/http/request.py
+++ b/netlib/http/request.py
@@ -10,10 +10,10 @@ from netlib.http import cookies
from netlib.odict import ODict
from .. import encoding
from .headers import Headers
-from .message import Message, _native, _always_bytes
+from .message import Message, _native, _always_bytes, MessageData
-class RequestData(object):
+class RequestData(MessageData):
def __init__(self, first_line_format, method, scheme, host, port, path, http_version, headers=None, content=None,
timestamp_start=None, timestamp_end=None):
if not headers:
@@ -32,14 +32,6 @@ class RequestData(object):
self.timestamp_start = timestamp_start
self.timestamp_end = timestamp_end
- def __eq__(self, other):
- if isinstance(other, RequestData):
- return self.__dict__ == other.__dict__
- return False
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
class Request(Message):
"""
diff --git a/netlib/http/response.py b/netlib/http/response.py
index db31d2b9..66e5ded6 100644
--- a/netlib/http/response.py
+++ b/netlib/http/response.py
@@ -4,12 +4,12 @@ import warnings
from . import cookies
from .headers import Headers
-from .message import Message, _native, _always_bytes
+from .message import Message, _native, _always_bytes, MessageData
from .. import utils
from ..odict import ODict
-class ResponseData(object):
+class ResponseData(MessageData):
def __init__(self, http_version, status_code, reason=None, headers=None, content=None,
timestamp_start=None, timestamp_end=None):
if not headers:
@@ -24,14 +24,6 @@ class ResponseData(object):
self.timestamp_start = timestamp_start
self.timestamp_end = timestamp_end
- def __eq__(self, other):
- if isinstance(other, ResponseData):
- return self.__dict__ == other.__dict__
- return False
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
class Response(Message):
"""
@@ -48,7 +40,7 @@ class Response(Message):
utils.pretty_size(len(self.content))
)
else:
- details = "content missing"
+ details = "no content"
return "Response({status_code} {reason}, {details})".format(
status_code=self.status_code,
reason=self.reason,