diff options
| author | Joe Gregorio <joe@bitworking.org> | 2009-07-16 12:28:04 -0400 |
|---|---|---|
| committer | Joe Gregorio <joe@bitworking.org> | 2009-07-16 12:28:04 -0400 |
| commit | b628c0b6acf4d5ce481391ace3d6c0410b2918fd (patch) | |
| tree | e27c75e2d1efe9935e2cdef9f830b03d172b02fa /python3 | |
| parent | 1a7609f7ede6ed44853bfee2a80dda98184d29b5 (diff) | |
| download | httplib2-b628c0b6acf4d5ce481391ace3d6c0410b2918fd.tar.gz | |
Fixed bug #56
Diffstat (limited to 'python3')
| -rwxr-xr-x | python3/httplib2/__init__.py | 4 | ||||
| -rwxr-xr-x | python3/httplib2test.py | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py index 9bf9136..d660796 100755 --- a/python3/httplib2/__init__.py +++ b/python3/httplib2/__init__.py @@ -845,7 +845,9 @@ the same interface as FileCache.""" else: raise else: - content = response.read() + content = b"" + if method != "HEAD": + content = response.read() response = Response(response) if method != "HEAD": content = _decompressContent(response, content) diff --git a/python3/httplib2test.py b/python3/httplib2test.py index e2bdae3..5b91164 100755 --- a/python3/httplib2test.py +++ b/python3/httplib2test.py @@ -185,6 +185,16 @@ class HttpTest(unittest.TestCase): (response, content) = self.http.request(uri, method, body=b" ")
self.assertEqual(response['x-method'], method)
+ def testHeadRead(self):
+ # Test that we don't try to read the response of a HEAD request
+ # since httplib blocks response.read() for HEAD requests.
+ # Oddly enough this doesn't appear as a problem when doing HEAD requests
+ # against Apache servers.
+ uri = "http://www.google.com/"
+ (response, content) = self.http.request(uri, "HEAD")
+ self.assertEqual(response.status, 200)
+ self.assertEqual(content, b"")
+
def testGetNoCache(self):
# Test that can do a GET w/o the cache turned on.
http = httplib2.Http()
|
