On this page
End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
Net::HTTPResponse
HTTP response class.
This class wraps together the response header and the response body (the entity requested).
It mixes in the HTTPHeader module, which provides access to response header values both via hash-like methods and via individual readers.
Note that each possible HTTP response code defines its own HTTPResponse subclass. All classes are defined under the Net module. Indentation indicates inheritance. For a list of the classes see Net::HTTP.
Correspondence HTTP code => class is stored in CODE_TO_OBJ constant:
Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
Class methods 4
Instance methods 6
The encoding to use for the response body. If Encoding, use that encoding. If other true value, attempt to detect the appropriate encoding, and use that.
The HTTP result code string. For example, ‘302’. You can also determine the response type by examining which response subclass the response object is an instance of.
Set to true automatically when the request did not contain an Accept-Encoding header from the user.
The HTTP version supported by the server.
Whether to ignore EOF when reading bodies with a specified Content-Length header.
The HTTP result message sent by the server. For example, ‘Not Found’.