首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Ruby Net:HTTP cheat sheet

2012-11-01 
Ruby Net::HTTP cheat sheet转自:http://augustl.com/blog/2010/ruby_net_http_cheat_sheet?I always have

Ruby Net::HTTP cheat sheet

转自:http://augustl.com/blog/2010/ruby_net_http_cheat_sheet

?

I always have to look up how to use Net::HTTP, and I never find what I’m looking for. Behold, a cheat sheet!

A basic request
??# Normal sslhttp.use_ssl = truehttp.verify_mode = OpenSSL::SSL::VERIFY_NONE# SSL .pem certspem = File.read("/path/to/my.pem")http.use_ssl = truehttp.cert = OpenSSL::X509::Certificate.new(pem)http.key = OpenSSL::PKey::RSA.new(pem)http.verify_mode = OpenSSL::SSL::VERIFY_PEER# Check for SSL dynamically. If your URI is https and you don't specify a# port, the port will be 443, which is the correct SSL port.http.use_ssl = (uri.port == 443)
?

热点排行