Skip to content
On this page

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class · Ruby 3.0

Net::HTTPResponse

< Object include Net::HTTPHeader 8 instance methods 4 class methods

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:

Example
Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound

Class methods 4

Instance methods 8

Constants
No documentation available
No documentation available
Attributes
Read

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.

Read & Write

Set to true automatically when the request did not contain an Accept-Encoding header from the user.

The HTTP version supported by the server.

Read

The HTTP result message sent by the server. For example, ‘Not Found’.

uri

Read

The URI used to fetch this response. The response URI is only available if a URI was used to create the request.