Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes issue 104.

  • Loading branch information...
commit d1137c5b87562b5b089997cc1ad6a1422d331097 1 parent f3ee17b
@jcgregorio jcgregorio authored
View
2  python2/httplib2/__init__.py
@@ -1060,7 +1060,7 @@ def request(self, uri, method="GET", body=None, headers=None, redirections=DEFAU
conn = self.connections[conn_key] = connection_type(authority, timeout=self.timeout, proxy_info=self.proxy_info)
conn.set_debuglevel(debuglevel)
- if method in ["GET", "HEAD"] and 'range' not in headers and 'accept-encoding' not in headers:
+ if 'range' not in headers and 'accept-encoding' not in headers:
headers['accept-encoding'] = 'gzip, deflate'
info = email.Message.Message()
View
7 python2/httplib2test.py
@@ -703,6 +703,13 @@ def testGetGZip(self):
self.assertEqual(int(response['content-length']), len("This is the final destination.\n"))
self.assertEqual(content, "This is the final destination.\n")
+ def testPostAndGZipResponse(self):
+ uri = urlparse.urljoin(base, "gzip/post.cgi")
+ (response, content) = self.http.request(uri, "POST", body=" ")
+ self.assertEqual(response.status, 200)
+ self.assertFalse(response.has_key('content-encoding'))
+ self.assertTrue(response.has_key('-content-encoding'))
+
def testGetGZipFailure(self):
# Test that we raise a good exception when the gzip fails
self.http.force_exception_to_status_code = False
View
2  python3/httplib2/__init__.py
@@ -1040,7 +1040,7 @@ def request(self, uri, method="GET", body=None, headers=None, redirections=DEFAU
conn = self.connections[conn_key] = connection_type(authority, timeout=self.timeout, proxy_info=self.proxy_info)
conn.set_debuglevel(debuglevel)
- if method in ["GET", "HEAD"] and 'range' not in headers and 'accept-encoding' not in headers:
+ if 'range' not in headers and 'accept-encoding' not in headers:
headers['accept-encoding'] = 'gzip, deflate'
info = email.message.Message()
View
7 python3/httplib2test.py
@@ -699,6 +699,13 @@ def testGetGZip(self):
self.assertEqual(int(response['content-length']), len(b"This is the final destination.\n"))
self.assertEqual(content, b"This is the final destination.\n")
+ def testPostAndGZipResponse(self):
+ uri = urllib.parse.urljoin(base, "gzip/post.cgi")
+ (response, content) = self.http.request(uri, "POST", body=" ")
+ self.assertEqual(response.status, 200)
+ self.assertFalse('content-encoding' in response)
+ self.assertTrue('-content-encoding' in response)
+
def testGetGZipFailure(self):
# Test that we raise a good exception when the gzip fails
self.http.force_exception_to_status_code = False
View
12 test/gzip/post.cgi
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+import zlib
+import os
+from StringIO import StringIO
+
+# Always returns a gzipped response body
+print "Status: 200 Ok"
+print ""
+
+print(zlib.compress('This is a compressed string'))
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.