def restart_http
@http.finish if @http
@http = Net::HTTP.new(@opts[:host], @opts[:port], @opts[:proxyHost], @opts[:proxyPort])
if @opts[:ssl]
require 'net/https'
@http.use_ssl = true
if @opts[:insecure]
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
else
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
end
@http.cert = OpenSSL::X509::Certificate.new(@opts[:cert]) if @opts[:cert]
@http.key = OpenSSL::PKey::RSA.new(@opts[:key]) if @opts[:key]
end
@http.set_debug_output(STDERR) if $DEBUG
@http.read_timeout = 1000000
@http.open_timeout = 5
def @http.on_connect
@socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
end
@http.start
end