Skip to content

Commit

Permalink
:query option no longer sets form data on post requests. Use :body op…
Browse files Browse the repository at this point in the history
…tion from now on.
  • Loading branch information
jnunemaker committed Jul 19, 2009
1 parent 756310f commit 49956a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 6 additions & 7 deletions lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ def http
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]
Expand Down
2 changes: 0 additions & 2 deletions spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def stub_response(body, code = 200)
end

describe 'with non-200 responses' do

it 'should return a valid object for 4xx response' do
stub_response '<foo><bar>yes</bar></foo>', 401
resp = @request.perform
Expand All @@ -130,7 +129,6 @@ def stub_response(body, code = 200)
resp.body.should == "<foo><bar>error</bar></foo>"
resp['foo']['bar'].should == "error"
end

end
end

Expand Down

0 comments on commit 49956a7

Please sign in to comment.