Checking response in Net::HTTP

How can I check if a requested document has a specific status (i.e. 200)
when using NET::HTTP?

Skave R. wrote:

How can I check if a requested document has a specific status (i.e. 200)
when using NET::HTTP?

This works for me:

Net::HTTPResponse::CODE_TO_OBJ.select { |k,v| v == response.class
}.first[0].to_i rescue 500

Hi,

2008/7/24 Skave R. [email protected]:

How can I check if a requested document has a specific status (i.e. 200)
when using NET::HTTP?

Posted via http://www.ruby-forum.com/.

res = Net::HTTP.get_response(‘www.ruby-lang.org’,‘/en/’)
puts res.code

Regards,

Park H.

res.code workes super, thanks