summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcgregorio <devnull@localhost>2006-11-17 21:52:34 +0000
committerjcgregorio <devnull@localhost>2006-11-17 21:52:34 +0000
commit772adc80e3d2ab4ef7bf32bdb6f1a7d502338f59 (patch)
treeaea0c1bbce3381e2b1ecd5e617b9c0c6143f35fe
parent90fb4a4de3f2697594865f81c5279f44c7b9852a (diff)
downloadhttplib2-772adc80e3d2ab4ef7bf32bdb6f1a7d502338f59.tar.gz
Changed -location header to content-location:
-rw-r--r--httplib2/__init__.py9
-rwxr-xr-xhttplib2test.py12
-rw-r--r--libhttplib2.tex2
-rw-r--r--ref/response-objects.html2
4 files changed, 14 insertions, 11 deletions
diff --git a/httplib2/__init__.py b/httplib2/__init__.py
index 162c05f..adc18a0 100644
--- a/httplib2/__init__.py
+++ b/httplib2/__init__.py
@@ -698,7 +698,8 @@ class Http:
response['location'] = urlparse.urljoin(absolute_uri, location)
if response.status == 301 and method in ["GET", "HEAD"]:
response['-x-permanent-redirect-url'] = response['location']
- response['-location'] = absolute_uri
+ if not response.has_key('content-location'):
+ response['content-location'] = absolute_uri
_updateCache(headers, response, content, self.cache, cachekey)
if headers.has_key('if-none-match'):
del headers['if-none-match']
@@ -707,7 +708,8 @@ class Http:
if response.has_key('location'):
location = response['location']
old_response = copy.deepcopy(response)
- old_response['-location'] = absolute_uri
+ if not old_response.has_key('content-location'):
+ old_response['content-location'] = absolute_uri
redirect_method = ((response.status == 303) and (method not in ["GET", "HEAD"])) and "GET" or method
(response, content) = self.request(location, redirect_method, body=body, headers = headers, redirections = redirections - 1)
response.previous = old_response
@@ -715,7 +717,8 @@ class Http:
raise RedirectLimit( _("Redirected more times than rediection_limit allows."))
elif response.status in [200, 203] and method == "GET":
# Don't cache 206's since we aren't going to handle byte range requests
- response['-location'] = absolute_uri
+ if not response.has_key('content-location'):
+ response['content-location'] = absolute_uri
_updateCache(headers, response, content, self.cache, cachekey)
return (response, content)
diff --git a/httplib2test.py b/httplib2test.py
index 35b72bc..2912217 100755
--- a/httplib2test.py
+++ b/httplib2test.py
@@ -163,15 +163,15 @@ class HttpTest(unittest.TestCase):
destination = urlparse.urljoin(base, "302/final-destination.txt")
(response, content) = self.http.request(uri, "GET")
self.assertEqual(response.status, 200)
- self.assertTrue(response.has_key('-location'))
- self.assertEqual(response['-location'], destination)
+ self.assertTrue(response.has_key('content-location'))
+ self.assertEqual(response['content-location'], destination)
self.assertEqual(content, "This is the final destination.\n")
self.assertEqual(response.previous.status, 301)
self.assertEqual(response.previous.fromcache, False)
(response, content) = self.http.request(uri, "GET")
self.assertEqual(response.status, 200)
- self.assertEqual(response['-location'], destination)
+ self.assertEqual(response['content-location'], destination)
self.assertEqual(content, "This is the final destination.\n")
self.assertEqual(response.previous.status, 301)
self.assertEqual(response.previous.fromcache, True)
@@ -183,7 +183,7 @@ class HttpTest(unittest.TestCase):
destination = urlparse.urljoin(base, "302/final-destination.txt")
(response, content) = self.http.request(uri, "GET")
self.assertEqual(response.status, 200)
- self.assertEqual(response['-location'], destination)
+ self.assertEqual(response['content-location'], destination)
self.assertEqual(content, "This is the final destination.\n")
self.assertEqual(response.previous.status, 302)
self.assertEqual(response.previous.fromcache, False)
@@ -192,11 +192,11 @@ class HttpTest(unittest.TestCase):
(response, content) = self.http.request(uri, "GET")
self.assertEqual(response.status, 200)
self.assertEqual(response.fromcache, True)
- self.assertEqual(response['-location'], destination)
+ self.assertEqual(response['content-location'], destination)
self.assertEqual(content, "This is the final destination.\n")
self.assertEqual(response.previous.status, 302)
self.assertEqual(response.previous.fromcache, False)
- self.assertEqual(response.previous['-location'], uri)
+ self.assertEqual(response.previous['content-location'], uri)
uri = urlparse.urljoin(base, "302/twostep.asis")
diff --git a/libhttplib2.tex b/libhttplib2.tex
index 8755256..2500336 100644
--- a/libhttplib2.tex
+++ b/libhttplib2.tex
@@ -289,7 +289,7 @@ going back through the responses to the very first response.
Will be \code{None} if there are no previous respones.
\end{memberdesc}
-The Response object also has a special key value \code{-location}, that
+The Response object also populates the header \code{content-location}, that
contains the URI that was ultimately requested. This is useful if
redirects were encountered, you can determine the ultimate URI that
the request was sent to. All Response objects contain this key value,
diff --git a/ref/response-objects.html b/ref/response-objects.html
index 49a3d67..28e585b 100644
--- a/ref/response-objects.html
+++ b/ref/response-objects.html
@@ -96,7 +96,7 @@ Will be <code>None</code> if there are no previous respones.
</dl>
<P>
-The Response object also has a special key value <code>-location</code>, that
+The Response object also populates the header <code>content-location</code>, that
contains the URI that was ultimately requested. This is useful if
redirects were encountered, you can determine the ultimate URI that
the request was sent to. All Response objects contain this key value,