Routes respond_to? to the referenced remote object.
Stop this server.
Routes respond_to? to the referenced remote object.
Posts HTML form data to the specified URI
object. The form data must be provided as a Hash
mapping from String
to String
. Example:
{ "cmd" => "search", "q" => "ruby", "max" => "50" }
This method also does Basic Authentication if and only if url
.user exists. But userinfo for authentication is deprecated (RFC3986). So this feature will be removed.
Example:
require 'net/http' Net::HTTP.post_form URI('http://www.example.com/search.cgi'), { "q" => "ruby", "max" => "50" }
Sends a GET request to the path
. Returns the response as a Net::HTTPResponse
object.
When called with a block, passes an HTTPResponse
object to the block. The body of the response will not have been read yet; the block can process it using HTTPResponse#read_body
, if desired.
Returns the response.
This method never raises Net::* exceptions.
response = http.request_get('/index.html') # The entity body is already read in this case. p response['content-type'] puts response.body # Using a block http.request_get('/index.html') {|response| p response['content-type'] response.read_body do |str| # read body now print str end }
Sends a HEAD request to the path
and returns the response as a Net::HTTPResponse
object.
Returns the response.
This method never raises Net::* exceptions.
response = http.request_head('/index.html') p response['content-type']
Sends an HTTP
request to the HTTP
server. Also sends a DATA string if data
is given.
Returns a Net::HTTPResponse
object.
This method never raises Net::* exceptions.
response = http.send_request('GET', '/index.html') puts response.body
Returns the full path for an HTTP
request, as required by Net::HTTP::Get
.
If the URI
contains a query, the full path is URI#path + ‘?’ + URI#query. Otherwise, the path is simply URI#path.
Example:
uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true') uri.request_uri # => "/foo/bar?test=true"