Method: Gem::Net::HTTP#send_request

Defined in:
lib/rubygems/vendor/net-http/lib/net/http.rb

#send_request(name, path, data = nil, header = nil) ⇒ Object

Sends an HTTP request to the server; returns an instance of a subclass of Gem::Net::HTTPResponse.

The request is based on the Gem::Net::HTTPRequest object created from string path, string data, and initial headers hash header. That object is an instance of the subclass of Gem::Net::HTTPRequest, that corresponds to the given uppercase string name, which must be an HTTP request method or a WebDAV request method.

Examples:

http = Gem::Net::HTTP.new(hostname)
http.send_request('GET', '/todos/1')
# => #<Gem::Net::HTTPOK 200 OK readbody=true>
http.send_request('POST', '/todos', 'xyzzy')
# => #<Gem::Net::HTTPCreated 201 Created readbody=true>


2337
2338
2339
2340
2341
# File 'lib/rubygems/vendor/net-http/lib/net/http.rb', line 2337

def send_request(name, path, data = nil, header = nil)
  has_response_body = name != 'HEAD'
  r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header)
  request r, data
end