summaryrefslogtreecommitdiff
path: root/python3/httplib2/__init__.py
diff options
context:
space:
mode:
authorJoe Gregorio <jcgregorio@google.com>2012-10-03 14:31:10 -0400
committerJoe Gregorio <jcgregorio@google.com>2012-10-03 14:31:10 -0400
commit46546a654e98355e76f1adb271400a0ca290e56c (patch)
tree289f342a25a89c10ddd08bd91ebb956f022f67ea /python3/httplib2/__init__.py
parenta97ff7f4dc5234dffff80f9da7eda58677170f7a (diff)
downloadhttplib2-46546a654e98355e76f1adb271400a0ca290e56c.tar.gz
Make httplib2.Http() instances pickleable.
Reviewed in https://codereview.appspot.com/6506074/
Diffstat (limited to 'python3/httplib2/__init__.py')
-rw-r--r--python3/httplib2/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index b42844f..de2cbd6 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -865,6 +865,20 @@ and more.
# Keep Authorization: headers on a redirect.
self.forward_authorization_headers = False
+ def __getstate__(self):
+ state_dict = copy.copy(self.__dict__)
+ # In case request is augmented by some foreign object such as
+ # credentials which handle auth
+ if 'request' in state_dict:
+ del state_dict['request']
+ if 'connections' in state_dict:
+ del state_dict['connections']
+ return state_dict
+
+ def __setstate__(self, state):
+ self.__dict__.update(state)
+ self.connections = {}
+
def _auth_from_challenge(self, host, request_uri, headers, response, content):
"""A generator that creates Authorization objects
that can be applied to requests.