From: Ian Cordasco Date: Sat, 20 Jul 2013 21:08:35 +0000 (-0400) Subject: Add copy method to PreparedRequest objects X-Git-Tag: 2.0~7^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b84547d78699a3a5c75dbdf2c2e422dbaa83b988;p=services%2Fpython-requests.git Add copy method to PreparedRequest objects --- diff --git a/requests/models.py b/requests/models.py index 3672b37..beaf04e 100644 --- a/requests/models.py +++ b/requests/models.py @@ -25,7 +25,7 @@ from .utils import ( stream_decode_response_unicode, to_key_val_list, parse_header_links, iter_slices, guess_json_utf, super_len) from .compat import ( - cookielib, urlparse, urlunparse, urlsplit, urlencode, str, bytes, StringIO, + cookielib, urlunparse, urlsplit, urlencode, str, bytes, StringIO, is_py2, chardet, json, builtin_str, basestring) CONTENT_CHUNK_SIZE = 10 * 1024 @@ -267,6 +267,15 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def __repr__(self): return '' % (self.method) + def copy(self): + p = PreparedRequest() + p.method = self.method + p.url = self.url + p.headers = self.headers + p.body = self.body + p.hooks = self.hooks + return p + def prepare_method(self, method): """Prepares the given HTTP method.""" self.method = method