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

A

Amit Bobade

Dear All:

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

<code>

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
response.error!
end
end

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

</code>

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

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

Thanks,
Amit
 
7

7stud --

Amit Bobade 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:

http://en.wikipedia.org/wiki/HTTP_302

===
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]
===
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top