Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/gist_store/net_http_ext.rb

Defined Under Namespace

Classes: Patch, Protocol

Instance Method Summary collapse

Instance Method Details

#__request__Object

Replace the request method in Net::HTTP to sniff the body type and set the stream if appropriate

Taken from: www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/



45
# File 'lib/gist_store/net_http_ext.rb', line 45

alias __request__ request

#request(req, body = nil, &block) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/gist_store/net_http_ext.rb', line 47

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