1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00
rest-client--rest-client/lib/restclient/net_http_ext.rb
François Beausoleil d3ab28688e Merge commit 'adamwiggins/multipart_streaming' into master
Conflicts:
	README.rdoc
	Rakefile
	lib/request_errors.rb
	lib/resource.rb
	lib/rest_client.rb
	lib/rest_client/request_errors.rb
	lib/rest_client/resource.rb
	lib/restclient/exceptions.rb
	lib/restclient/resource.rb
	rest-client.gemspec
	spec/base.rb
	spec/rest_client_spec.rb
2009-08-12 11:00:44 -04:00

21 lines
469 B
Ruby

#
# Replace the request method in Net::HTTP to sniff the body type
# and set the stream if appropriate
#
# Taken from:
# http://www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/
module Net
class HTTP
alias __request__ request
def request(req, body=nil, &block)
if body != nil && body.respond_to?(:read)
req.body_stream = body
return __request__(req, nil, &block)
else
return __request__(req, body, &block)
end
end
end
end