最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ruby HTTP Reponse的使用方法
时间:2011-06-06 编辑:简简单单 来源:一聚教程网
ruby HTTP Reponse的使用方法
require 'net/http'
h = Net::HTTP.new('www.google.com', 80)
response = h.get('/index.html', nil)
if response.message == "OK"
puts response.body.scan(/
end
get response 代码
require 'uri'
Net::HTTP.get(URI.parse("http://www.111com.net"))
response = Net::HTTP.get_response('www.111com.net', '/about/')
puts case response.code[0] # Check the first byte of the response code.
when ?1 then "Status code indicates an HTTP informational response."
when ?2 then "Status code indicates success."
when ?3 then "Status code indicates redirection."
when ?4 then "Status code indicates client error."
when ?5 then "Status code indicates server error."
else "Non-standard status code."
end
获取远程地址
require 'uri'
Net::HTTP.get(URI.parse("http://www.111com.net"))
response = Net::HTTP.get_response('www.111com.net', '/about/')
puts "Success!" if response.is_a? Net::HTTPOK
# Success!
-
上一个: php update数据更新简单实例
-
下一个: apache 301重定向的详细做法
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24