HTTPretty
HTTPretty copied to clipboard
Support for different content encodings or raw bodies
As far as I can tell, there is no way to test with a response where the content encoding is gzip or some other compression. The body gets mangled in the process, probably by the utf8 handling.
:+1: for gzip encoding
mean that?
gzip:
import StringIO
import gzip
import httpretty
plain_file = StringIO.StringIO()
gzip_file = gzip.GzipFile(fileobj=plain_file, mode='w')
gzip_file.writelines('I am gzip')
gzip_file.close()
gzip_str = plain_file.getvalue()
plain_file.close()
httpretty.register_uri(
httpretty.GET, 'http://www.example.com/', status=200, body=gzip_str,
forcing_headers={'content-encoding': 'gzip'}
)
deflate:
import zlib
import httpretty
deflate_str = zlib.compress('I am deflate')
httpretty.register_uri(
httpretty.GET, 'http://www.example.com/', status=200, body=deflate_str,
forcing_headers={'content-encoding': 'deflate'}
)