From 50c46e2e40211779f58f91925aad73b74216d96b Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Mon, 3 Mar 2014 10:54:35 -0900 Subject: [PATCH 1/2] added the possibility to specify a body_stream in HttpRequest --- lib/httparty/request.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 065acd4..9d61d69 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -148,6 +148,7 @@ module HTTParty def setup_raw_request @raw_request = http_method.new(request_uri(uri)) @raw_request.body = body if body + @raw_request.body_stream = options[:body_stream] if options[:body_stream] @raw_request.initialize_http_header(options[:headers]) @raw_request.basic_auth(username, password) if options[:basic_auth] setup_digest_auth if options[:digest_auth] From 604bfa6b88d0dbdca2aa30dabad1ffd2b723daf6 Mon Sep 17 00:00:00 2001 From: Heinrich Klobuczek Date: Wed, 5 Mar 2014 09:48:36 -0900 Subject: [PATCH 2/2] added a spec for body_stream --- spec/httparty/request_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index e86d7e9..519f023 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -117,6 +117,13 @@ describe HTTParty::Request do @post_request.options[:digest_auth] = {:username => 'foobar', :password => 'secret'} @post_request.send(:setup_raw_request) end + + it 'should use body_stream when configured' do + stream = StringIO.new('foo') + request = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body_stream: stream) + request.send(:setup_raw_request) + request.instance_variable_get(:@raw_request).body_stream.should == stream + end end describe "#uri" do