Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #275 from klobuczek/master

added the possibility to specify a body_stream in HttpRequest
  • Loading branch information...
commit 2ea1499bf455d88e75f933670f54828a0afe20ad 2 parents 036b783 + 604bfa6
@jnunemaker authored
Showing with 8 additions and 0 deletions.
  1. +1 −0  lib/httparty/request.rb
  2. +7 −0 spec/httparty/request_spec.rb
View
1  lib/httparty/request.rb
@@ -148,6 +148,7 @@ def query_string_normalizer
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]
View
7 spec/httparty/request_spec.rb
@@ -117,6 +117,13 @@
@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
Please sign in to comment.
Something went wrong with that request. Please try again.