Created
May 20, 2013 20:30
-
-
Save calebwoods/5615260 to your computer and use it in GitHub Desktop.
Testing helper methods to use with Rack::Deflater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def api_post_gziped(url, params={}, api_token = 'test_token') | |
gzipped_data = ActiveSupport::Gzip.compress(params.to_json) | |
post(url, gzipped_data, headers.merge('HTTP_AUTHORIZATION' => basic_auth_for(api_token), | |
"HTTP_ACCEPT_ENCODING" => "gzip", | |
'CONTENT_TYPE' => 'gzip/json')) | |
end | |
def decompressed_json_body | |
Yajl::Parser.parse(ActiveSupport::Gzip.decompress(response.body)) | |
end | |
def headers | |
{ 'CONTENT_TYPE' => 'application/json', | |
'HTTP_ACCEPT' => 'application/json', | |
'HTTP_USER_AGENT' => 'Test Client' } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment