examples/http_proxy.rb in em-proxy-0.1.6 vs examples/http_proxy.rb in em-proxy-0.1.7

- old
+ new

@@ -1,11 +1,12 @@ require 'em-proxy' require 'http/parser' # gem install http_parser.rb require 'uuid' # gem install uuid -# > ruby em-proxy-http.rb +# > ruby http_proxy.rb # > curl --proxy localhost:9889 www.google.com +# > curl --proxy x.x.x.x:9889 www.google.com - bind ip example host = "0.0.0.0" port = 9889 puts "listening on #{host}:#{port}..." @@ -15,10 +16,11 @@ @p.on_headers_complete = proc do |h| session = UUID.generate puts "New session: #{session} (#{h.inspect})" host, port = h['Host'].split(':') - conn.server session, :host => host, :port => (port || 80) + conn.server session, :host => host, :port => (port || 80) #, :bind_host => conn.sock[0] - # for bind ip + conn.relay_to_servers @buffer @buffer.clear end