diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 7370f7b..90e47cb 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -51,15 +51,14 @@ module HTTParty def configure_basic_auth @raw_request.basic_auth(options[:basic_auth][:username], options[:basic_auth][:password]) end + + def body + options[:body].is_a?(Hash) ? options[:body].to_params : options[:body] + end def setup_raw_request - @raw_request = http_method.new(uri.request_uri) - - if post? && options[:query] - @raw_request.set_form_data(options[:query]) - end - - @raw_request.body = options[:body].is_a?(Hash) ? options[:body].to_params : options[:body] unless options[:body].blank? + @raw_request = http_method.new(uri.request_uri) + @raw_request.body = body if body @raw_request.initialize_http_header options[:headers] configure_basic_auth if options[:basic_auth] diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 95541d4..a393038 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -114,7 +114,6 @@ describe HTTParty::Request do end describe 'with non-200 responses' do - it 'should return a valid object for 4xx response' do stub_response 'yes', 401 resp = @request.perform @@ -130,7 +129,6 @@ describe HTTParty::Request do resp.body.should == "error" resp['foo']['bar'].should == "error" end - end end