url = URI.parse("http://www.google.com/")
@req = Net::HTTP.new(url.host)
@req.start() do |req|
x = req.head(url.path)
print x
end
It will print
#<Net::HTTPFound:0xe70e30>
From Object x i am not able to get only the result (ie. Not found)
Any methods associate with x to get status code alone.
If there is Some other way to get status code of the url, then also
please reply me...
···
--
Posted via http://www.ruby-forum.com/.
Net::HTTP#start doesn't do the request
require 'net/http'
url = URI.parse("http://www.google.com")
req = Net::HTTP.new(url.host)
req.request_get("/") do |res|
puts res.code
end
···
On Thu, Dec 18, 2008 at 8:06 AM, Desingurajan Aswanthaaman < desingurajan@gmail.com> wrote:
url = URI.parse("http://www.google.com/"\)
@req = Net::HTTP.new(url.host)
@req.start() do |req|
x = req.head(url.path)
print x
end
It will print
#<Net::HTTPFound:0xe70e30>
From Object x i am not able to get only the result (ie. Not found)
Any methods associate with x to get status code alone.
If there is Some other way to get status code of the url, then also
please reply me...
--
Posted via http://www.ruby-forum.com/\.
May be helpful, Only requesting header
require 'net/http'
url = URI.parse("http://www.google.com/")
req = Net::HTTP.new(url.host)
req.start() do |req|
x = req.head(url.path)
puts x.code
puts x.message
x.each {|key, val| print key," = ",val,"\n" }
end
···
--
Posted via http://www.ruby-forum.com/.