Ruby Net::HTTP Functions
EditRocket provides the following information on Net::HTTP functions in the Ruby source code builder.
active?() - "Alias for #started?"
copy(path, initheader = nil) - Sends a COPY request to the path and gets a response, as an HTTPResponse object.
default_port() - The default port to use for HTTP requests; defaults to 80.
delete(path, initheader = {'Depth' => 'Infinity'}) - Sends a DELETE request to the path and gets a response, as an HTTPResponse object.
finish() - Finishes HTTP session and closes TCP connection. Raises IOError if not started.
get(uri_or_host, path = nil, port = nil) - "Send a GET request to the target and return the response as a string. The target can either be specified as (uri), or as (host, path, port = 80); so:"
get(uri_or_host, path = nil, port = nil) - "Send a GET request to the target and return the response as a string. The target can either be specified as (uri), or as (host, path, port = 80); so:"
get2(path, initheader = nil) - "Alias for #request_get"
get_print(uri_or_host, path = nil, port = nil) - "Get body from target and output it to +$stdout+. The target can either be specified as (uri), or as (host, path, port = 80); so:"
get_response(uri_or_host, path = nil, port = nil, &block) - "Send a GET request to the target and return the response as a Net::HTTPResponse object. The target can either be specified as (uri), or as (host, path, port = 80); so:"
head(path, initheader = nil) - Gets only the header from path on the connected-to host. header is a Hash like { 'Accept' => '*/*', ... }.
head2(path, initheader = nil, &block) - "Alias for #request_head"
http_default_port() - The default port to use for HTTP requests; defaults to 80.
https_default_port() - The default port to use for HTTPS requests; defaults to 443.
inspect() -
lock(path, body, initheader = nil) - Sends a LOCK request to the path and gets a response, as an HTTPResponse object.
mkcol(path, body = nil, initheader = nil) - Sends a MKCOL request to the path and gets a response, as an HTTPResponse object.
move(path, initheader = nil) - Sends a MOVE request to the path and gets a response, as an HTTPResponse object.
new(address, port = nil) - Creates a new Net::HTTP object for the specified address. This method does not open the TCP connection.
options(path, initheader = nil) - Sends a OPTIONS request to the path and gets a response, as an HTTPResponse object.
peer_cert() -
post(path, data, initheader = nil, dest = nil) - Posts data (must be a String) to path. header must be a Hash like { 'Accept' => '*/*', ... }.
post2(path, data, initheader = nil) - "Alias for #request_post"
post_form(url, params) - "Posts HTML form data to the URL. Form data must be represented as a Hash of String to String, e.g:"
propfind(path, body = nil, initheader = {'Depth' => '0'}) - Sends a PROPFIND request to the path and gets a response, as an HTTPResponse object.
proppatch(path, body, initheader = nil) - Sends a PROPPATCH request to the path and gets a response, as an HTTPResponse object.
proxy?() - True if self is a HTTP proxy class.
Proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil) - Creates an HTTP proxy class. Arguments are address/port of proxy host and username/password if authorization on proxy server is required. You can replace the HTTP class with created proxy class.
proxy_address() - Address of proxy host. If self does not use a proxy, nil.
proxy_class?() - returns true if self is a class which was created by HTTP::Proxy.
proxy_pass() - User password for accessing proxy. If self does not use a proxy, nil.
proxy_port() - Port number of proxy host. If self does not use a proxy, nil.
proxy_user() - User name for accessing proxy. If self does not use a proxy, nil.
proxyaddr() - "Alias for #proxy_address"
proxyport() - "Alias for #proxy_port"
read_timeout=(sec) - Setter for the read_timeout attribute.
request(req, body = nil) - Sends an HTTPRequest object REQUEST to the HTTP server. This method also sends DATA string if REQUEST is a post/put request. Giving DATA for get/head request causes ArgumentError.
request_get(path, initheader = nil) - Sends a GET request to the path and gets a response, as an HTTPResponse object.
request_head(path, initheader = nil, &block) - Sends a HEAD request to the path and gets a response, as an HTTPResponse object.
request_post(path, data, initheader = nil) - Sends a POST request to the path and gets a response, as an HTTPResponse object.
send_request(name, path, data = nil, header = nil) - Sends an HTTP request to the HTTP server. This method also sends DATA string if DATA is given.
set_debug_output(output) - WARNING This method causes serious security hole. Never use this method in production code.
ssl_context_accessor(name) -
ssl_timeout=(sec) -
ssl_timeout() -
start(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) - creates a new Net::HTTP object and opens its TCP connection and HTTP session. If the optional block is given, the newly created Net::HTTP object is passed to it and closed when the block finishes. In this case, the return value of this method is the return value of the block. If no block is given, the return value of this method is the newly created Net::HTTP object itself, and the caller is responsible for closing it upon completion.
start(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) - creates a new Net::HTTP object and opens its TCP connection and HTTP session. If the optional block is given, the newly created Net::HTTP object is passed to it and closed when the block finishes. In this case, the return value of this method is the return value of the block. If no block is given, the return value of this method is the newly created Net::HTTP object itself, and the caller is responsible for closing it upon completion.
started?() - returns true if the HTTP session is started.
timeout=(sec) - "Alias for #ssl_timeout="
trace(path, initheader = nil) - Sends a TRACE request to the path and gets a response, as an HTTPResponse object.
unlock(path, body, initheader = nil) - Sends a UNLOCK request to the path and gets a response, as an HTTPResponse object.
use_ssl=(flag) - Turn on/off SSL. This flag must be set before starting session. If you change use_ssl value after session started, a Net::HTTP object raises IOError.
use_ssl?() -
use_ssl() - "Alias for #use_ssl?"
version_1_1?() - true if net/http is in version 1.1 compatible mode. Defaults to true.
version_1_1() - Turns on net/http 1.1 (ruby 1.6) features. Defaults to OFF in ruby 1.8.
version_1_2?() - true if net/http is in version 1.2 mode. Defaults to true.
version_1_2() - Turns on net/http 1.2 (ruby 1.8) features. Defaults to ON in ruby 1.8.