Raised when the provided IP address is an invalid address.
Raised when the address family is invalid such as an address with an unsupported family, an address with an inconsistent family, or an address who’s family cannot be determined.
This class is the base class for Net::HTTP request classes; it wraps together the request path and the request headers.
The class should not be used directly; instead you should use its subclasses.
Subclasses for HTTP requests:
Subclasses for WebDAV requests:
This class is the base class for Net::HTTP request classes.
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):
Hash-like method []
.
Specific reader methods, such as content_type
.
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"
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):
Net::HTTPUnknownResponse
(for unhandled HTTP extensions).
Net::HTTPContinue
(100)
Net::HTTPSwitchProtocol
(101)
Net::HTTPProcessing
(102)
Net::HTTPEarlyHints
(103)
Net::HTTPOK
(200)
Net::HTTPCreated
(201)
Net::HTTPAccepted
(202)
Net::HTTPNoContent
(204)
Net::HTTPResetContent
(205)
Net::HTTPPartialContent
(206)
Net::HTTPMultiStatus
(207)
Net::HTTPAlreadyReported
(208)
Net::HTTPIMUsed
(226)
Net::HTTPMultipleChoices
(300)
Net::HTTPFound
(302)
Net::HTTPSeeOther
(303)
Net::HTTPNotModified
(304)
Net::HTTPUseProxy
(305)
Net::HTTPBadRequest
(400)
Net::HTTPUnauthorized
(401)
Net::HTTPPaymentRequired
(402)
Net::HTTPForbidden
(403)
Net::HTTPNotFound
(404)
Net::HTTPNotAcceptable
(406)
Net::HTTPRequestTimeOut
(408)
Net::HTTPConflict
(409)
Net::HTTPGone
(410)
Net::HTTPLengthRequired
(411)
Net::HTTPLocked
(423)
Net::HTTPUpgradeRequired
(426)
Net::HTTPTooManyRequests
(429)
Net::HTTPNotImplemented
(501)
Net::HTTPBadGateway
(502)
Net::HTTPGatewayTimeOut
(504)
Net::HTTPLoopDetected
(508)
Net::HTTPNotExtended
(510)
There is also the Net::HTTPBadResponse exception which is raised when there is a protocol error.
Parent class for redirection (3xx) HTTP
response classes.
A redirection response indicates the client must take additional action to complete the request.
References:
Parent class for client error (4xx) HTTP
response classes.
A client error response indicates that the client may have caused an error.
References:
Parent class for server error (5xx) HTTP
response classes.
A server error response indicates that the server failed to fulfill a request.
References:
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. See 204 No Content.
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. See 205 Reset Content.
Response class for Request Timeout
responses (status code 408).
The server timed out waiting for the request. See 408 Request Timeout.
Response class for Request Timeout
responses (status code 408).
The server timed out waiting for the request. See 408 Request Timeout.
Response class for Precondition Failed
responses (status code 412).
The server does not meet one of the preconditions specified in the request headers. See 412 Precondition Failed.
Response class for Range Not Satisfiable
responses (status code 416).
The request entity has a media type which the server or resource does not support. See 416 Range Not Satisfiable.
Response class for Range Not Satisfiable
responses (status code 416).
The request entity has a media type which the server or resource does not support. See 416 Range Not Satisfiable.
Response class for Locked (WebDAV)
responses (status code 423).
The requested resource is locked. See 423 Locked (WebDAV).
Response class for Precondition Required
responses (status code 428).
The origin server requires the request to be conditional. See 428 Precondition Required.
Response class for Internal Server Error
responses (status code 500).
An unexpected condition was encountered and no more specific message is suitable. See 500 Internal Server Error.
Raised on redirection, only occurs when redirect
option for HTTP is false
.
Base class of exceptions from OptionParser
.
The error type thrown by all PStore
methods.