Ruby Http 基础库学习 2018 程序啪啪啪
网络http请相关学习
基础方法
- URI
- 产生连接
- 连接内部进行请求
require 'uri'
require 'net/http'
uri = URI('http://example.com/some_path?query=string')
Net::HTTP.start(uri.host, uri.port) do |http|
request = Net::HTTP::Get.new uri
response = http.request request # Net::HTTPResponse object
request = Net::HTTP::Put.new uri
end
服务端
require 'webrick'
include WEBrick
port=8080
puts "Starting server: http://#{Socket.gethostname}:#{port}"
server = HTTPServer.new(:Port=>port,:DocumentRoot=>Dir::pwd )
trap("INT"){ server.shutdown }
server.start
常见问题
- 代理
- multimeta 表单
- Auth
- stream IO
- 性能
- http/sql 连接池技术
- HTTP KeepAlive
创建@
2016-03-06
最后修改@
2016-03-06