文件存放 url 地址,依次读取,正常的测试:输出每一行,是没问题的。 但采用下述代码在 41 行的时候出现 EOFError 错误 查看了一下,uri 和 http 建立正常 在 response = http.request request 出错
是什么原因呢
ruby:2.0.0.0p
@file.each_line do |line|
count +=1
puts "count:#{count} #{line}"
url = line.chomp
uri=URI(url)
puts url.unpack("H*")
uri += "/web.config"
begin
http = Net::HTTP.start(uri.host,uri.port)
request = Net::HTTP::Get.new uri
response = http.request request
status = response.code
if( "404" != status ) then
puts "#{status} || #{uri}"
end
rescue Errno::ETIMEDOUT
puts "error:ETIMEOUT"
end
end
错误提示:
count:41 http://www.ahkytb.com 687474703a2f2f7777772e61686b7974622e636f6d /home/april/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/protocol.rb:153:in `read_nonblock': end of file reached (EOFError)