Created
March 26, 2011 15:38
-
-
Save ms-ati/888383 to your computer and use it in GitHub Desktop.
HTTParty Issue 78: Can't see Response Body causing Crack::ParseError
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'httparty' | |
class FakeRestJsonApi | |
include HTTParty | |
base_uri 'http://google.com/THIS_IS_A_FAKE_URL' | |
headers 'Accept' => 'application/json' | |
default_params :output => 'json' | |
format :json | |
def fake_get_request(params={}) | |
self.class.get('/fake_get_request', :body => params) | |
end | |
end | |
if __FILE__ == $0 | |
frj_api = FakeRestJsonApi.new | |
# | |
# NOTE: | |
# How can one retrieve the Response Body which causes the | |
# the Crack::ParseError in order to log and debug? | |
# | |
begin | |
resp = frj_api.fake_get_request | |
rescue Exception => e | |
require 'pp' | |
puts "\n--------------\nResponse from fake_get_request:\n\n" | |
pp resp | |
puts "\n--------------\n\n" | |
raise | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment