读书人

Ruby Net:HTTP cheat sheet

发布时间: 2012-11-01 11:11:31 作者: rapoo

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)
?

读书人网 >Ruby Rails

热点推荐