mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Merge pull request #275 from klobuczek/master
added the possibility to specify a body_stream in HttpRequest
This commit is contained in:
commit
2ea1499bf4
2 changed files with 8 additions and 0 deletions
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue