aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/headers.py5
-rw-r--r--netlib/http/message.py4
-rw-r--r--netlib/http/request.py3
-rw-r--r--netlib/http/response.py3
-rw-r--r--netlib/utils.py3
5 files changed, 7 insertions, 11 deletions
diff --git a/netlib/http/headers.py b/netlib/http/headers.py
index 9b8fdae4..bcb828da 100644
--- a/netlib/http/headers.py
+++ b/netlib/http/headers.py
@@ -5,7 +5,7 @@ Unicode Handling
See also: http://lucumr.pocoo.org/2013/7/2/the-updated-guide-to-unicode/
"""
from __future__ import absolute_import, print_function, division
-import copy
+
try:
from collections.abc import MutableMapping
except ImportError: # pragma: no cover
@@ -190,9 +190,6 @@ class Headers(MutableMapping, Serializable):
[name, value] for value in values
)
- def copy(self):
- return Headers(copy.copy(self.fields))
-
def get_state(self):
return tuple(tuple(field) for field in self.fields)
diff --git a/netlib/http/message.py b/netlib/http/message.py
index b6d846ba..b265ac4f 100644
--- a/netlib/http/message.py
+++ b/netlib/http/message.py
@@ -43,9 +43,6 @@ class MessageData(utils.Serializable):
class Message(utils.Serializable):
- def __init__(self, data):
- self.data = data
-
def __eq__(self, other):
if isinstance(other, Message):
return self.data == other.data
@@ -62,6 +59,7 @@ class Message(utils.Serializable):
@classmethod
def from_state(cls, state):
+ state["headers"] = Headers.from_state(state["headers"])
return cls(**state)
@property
diff --git a/netlib/http/request.py b/netlib/http/request.py
index d35c1874..5bd2547e 100644
--- a/netlib/http/request.py
+++ b/netlib/http/request.py
@@ -42,8 +42,7 @@ class Request(Message):
An HTTP request.
"""
def __init__(self, *args, **kwargs):
- data = RequestData(*args, **kwargs)
- super(Request, self).__init__(data)
+ self.data = RequestData(*args, **kwargs)
def __repr__(self):
if self.host and self.port:
diff --git a/netlib/http/response.py b/netlib/http/response.py
index da2c8142..8af3c041 100644
--- a/netlib/http/response.py
+++ b/netlib/http/response.py
@@ -29,8 +29,7 @@ class Response(Message):
An HTTP response.
"""
def __init__(self, *args, **kwargs):
- data = ResponseData(*args, **kwargs)
- super(Response, self).__init__(data)
+ self.data = ResponseData(*args, **kwargs)
def __repr__(self):
if self.content:
diff --git a/netlib/utils.py b/netlib/utils.py
index f7bb5c4b..09be29d9 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -41,6 +41,9 @@ class Serializable(object):
"""
raise NotImplementedError()
+ def copy(self):
+ return self.from_state(self.get_state())
+
def always_bytes(unicode_or_bytes, *encode_args):
if isinstance(unicode_or_bytes, six.text_type):