Results for: "module_function"

No documentation available

This class is the base class for Net::HTTP response classes.

About the Examples

Returned Responses

Method Net::HTTP.get_response returns an instance of one of the subclasses of Net::HTTPResponse:

Net::HTTP.get_response(uri)
# => #<Net::HTTPOK 200 OK readbody=true>
Net::HTTP.get_response(hostname, '/nosuch')
# => #<Net::HTTPNotFound 404 Not Found readbody=true>

As does method Net::HTTP#request:

req = Net::HTTP::Get.new(uri)
Net::HTTP.start(hostname) do |http|
  http.request(req)
end # => #<Net::HTTPOK 200 OK readbody=true>

Class Net::HTTPResponse includes module Net::HTTPHeader, which provides access to response header values via (among others):

Examples:

res = Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true>
res['Content-Type']               # => "text/html; charset=UTF-8"
res.content_type                  # => "text/html"

Response Subclasses

Class Net::HTTPResponse has a subclass for each HTTP status code. You can look up the response class for a given code:

Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK
Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest
Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound

And you can retrieve the status code for a response object:

Net::HTTP.get_response(uri).code                 # => "200"
Net::HTTP.get_response(hostname, '/nosuch').code # => "404"

The response subclasses (indentation shows class hierarchy):

There is also the Net::HTTPBadResponse exception which is raised when there is a protocol error.

Response class for No Content responses (status code 204).

The No Content response indicates that the server successfully processed the request, and is not returning any content.

References:

Response class for Reset Content responses (status code 205).

The Reset Content response indicates that the server successfully processed the request, asks that the client reset its document view, and is not returning any content.

References:

Response class for Found responses (status code 302).

The Found response indicates that the client should look at (browse to) another URL.

References:

Response class for Temporary Redirect responses (status code 307).

The request should be repeated with another URI; however, future requests should still use the original URI.

References:

Response class for Permanent Redirect responses (status code 308).

This and all future requests should be directed to the given URI.

References:

Response class for Unauthorized responses (status code 401).

Authentication is required, but either was not provided or failed.

References:

Response class for Not Found responses (status code 404).

The requested resource could not be found but may be available in the future.

References:

Response class for Request Timeout responses (status code 408).

The server timed out waiting for the request.

References:

Response class for Request Timeout responses (status code 408).

The server timed out waiting for the request.

References:

Response class for Gone responses (status code 410).

The resource requested was previously in use but is no longer available and will not be available again.

References:

Response class for Payload Too Large responses (status code 413).

The request is larger than the server is willing or able to process.

References:

Response class for URI Too Long responses (status code 414).

The URI provided was too long for the server to process.

References:

Response class for URI Too Long responses (status code 414).

The URI provided was too long for the server to process.

References:

Response class for Unsupported Media Type responses (status code 415).

The request entity has a media type which the server or resource does not support.

References:

Response class for Misdirected Request responses (status code 421).

The request was directed at a server that is not able to produce a response.

References:

Response class for Gateway Timeout responses (status code 504).

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

References:

Response class for Gateway Timeout responses (status code 504).

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

References:

Response class for Loop Detected (WebDAV) responses (status code 508).

The server detected an infinite loop while processing the request.

References:

No documentation available

OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be created within the open_timeout.

ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the response cannot be read within the read_timeout.

WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the response cannot be written within the write_timeout. Not raised on Windows.

Raised on redirection, only occurs when redirect option for HTTP is false.

Search took: 5ms  ·  Total Results: 5313