What is the meaning of #<Net::HTTPFound:0x29b78f8>

Dear All:

I am trying to deal with the http response. I am using following code to
do so.

require ‘net/http’
require ‘uri’

def fetch(uri_str, limit = 10)
  # You should choose better exception.
  raise ArgumentError, 'HTTP redirect too deep' if limit == 0

  response = Net::HTTP.get_response(URI.parse(uri_str))
  case response
  when Net::HTTPSuccess     then response
  when Net::HTTPRedirection then fetch(response['location'], limit -
  1. else

    print fetch(‘http://www.gosocially.com/index.php’)

I am getting output: #Net::HTTPFound:0x29b78f8

Please tell me what is the meaning of #Net::HTTPFound:0x29b78f8 ?


Amit B. wrote in post #1001497:

Please tell me what is the meaning of #Net::HTTPFound:0x29b78f8 ?

According to ruby’s Net::HTTPResponse docs:

xxx HTTPResponse

1xx        HTTPInformation
  100        HTTPContinue
  101        HTTPSwitchProtocol

2xx        HTTPSuccess
  200        HTTPOK
  201        HTTPCreated
  202        HTTPAccepted
  203        HTTPNonAuthoritativeInformation
  204        HTTPNoContent
  205        HTTPResetContent
  206        HTTPPartialContent

3xx        HTTPRedirection
  300        HTTPMultipleChoice
  301        HTTPMovedPermanently
  302        HTTPFound

And according to wikipedia here:


the response code 302 means:

The HTTP response status code 302 Found is the most common way of
performing a redirection.[citation needed]

It is an example of industry practice contradicting the standard
HTTP/1.0 specification (RFC 1945), which required the client to perform
a temporary redirect (the original describing phrase was “Moved
Temporarily”), but popular browsers implemented it as a 303 See
Other[citation needed], i.e. changing the request type to GET regardless
of what it had been originally. Therefore, HTTP/1.1 added status codes
303 and 307 to disambiguate between the two behaviours. However, the
majority of Web applications and frameworks still use the 302 status
code as if it were the 303.[citation needed]

Amit B. [email protected] wrote:

 # You should choose better exception.


print fetch(‘http://www.gosocially.com/index.php’)

I am getting output: #Net::HTTPFound:0x29b78f8

Please tell me what is the meaning of #Net::HTTPFound:0x29b78f8 ?

Did you read any of the documentation? Net::HTTP.get_response returns a
response object, because an HTTP request returns several different kinds
things. What you are seeing there is the string representation of an

Are you expecting to print the body of the web page? If so, then you
should print response.body, not response.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs