From 46546a654e98355e76f1adb271400a0ca290e56c Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Wed, 3 Oct 2012 14:31:10 -0400 Subject: Make httplib2.Http() instances pickleable. Reviewed in https://codereview.appspot.com/6506074/ --- python3/httplib2/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'python3/httplib2') 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. -- cgit v1.2.1