From e3c7b43fc98aab11bd228498a775a528a06429f0 Mon Sep 17 00:00:00 2001 From: Smiley Barry Date: Mon, 6 Apr 2015 21:00:51 +0300 Subject: [PATCH] #2532: Documented strange behaviour in "PreparedRequest.prepare_cookies", caused by cookielib. Also documented a workaround if absolutely necessary. --- requests/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index 12304adb2b..806004c03b 100644 --- a/requests/models.py +++ b/requests/models.py @@ -501,7 +501,15 @@ def prepare_auth(self, auth, url=''): self.prepare_content_length(self.body) def prepare_cookies(self, cookies): - """Prepares the given HTTP cookie data.""" + """Prepares the given HTTP cookie data. + + This function eventually generates a ``Cookie`` header from the + given cookies using cookielib. Due to cookielib's design, the header + will not be regenerated if it already exists, meaning this function + can only be called once for the life of the + :class:`PreparedRequest ` object. Any subsequent calls + to ``prepare_cookies`` will have no actual effect, unless the "Cookie" + header is removed beforehand.""" if isinstance(cookies, cookielib.CookieJar): self._cookies = cookies