instance method
Net::HTTP#send_request
(::String name, ::String path, ?::String? data, ?::Net::headers? header) -> ::Net::HTTPResponse
send_request(name, path, data = nil, header = nil)
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/net/http.rb, line 2363
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
Sends an HTTP request to the server; returns an instance of a subclass of Net::HTTPResponse.
The request is based on the Net::HTTPRequest object created from string path, string data, and initial headers hash header. That object is an instance of the subclass of Net::HTTPRequest, that corresponds to the given uppercase string name, which must be an HTTP request method or a WebDAV request method.
Examples:
Example
http = Net::HTTP.new(hostname) http.send_request('GET', '/todos/1') # => #<Net::HTTPOK 200 OK readbody=true> http.send_request('POST', '/todos', 'xyzzy') # => #<Net::HTTPCreated 201 Created readbody=true>
See also
#send_entity
#set_debug_output
#response_body_encoding=
#start
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0