Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for different content encodings or raw bodies #62

Open
oschwald opened this issue May 6, 2013 · 2 comments
Open

Support for different content encodings or raw bodies #62

oschwald opened this issue May 6, 2013 · 2 comments

Comments

@oschwald
Copy link
Contributor

oschwald commented May 6, 2013

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.

@rgbkrk
Copy link
Contributor

rgbkrk commented Jan 3, 2014

👍 for gzip encoding

@akun
Copy link
Contributor

akun commented May 19, 2014

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'}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants