From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/sample/webrick/httpproxy.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 jni/ruby/sample/webrick/httpproxy.rb (limited to 'jni/ruby/sample/webrick/httpproxy.rb') diff --git a/jni/ruby/sample/webrick/httpproxy.rb b/jni/ruby/sample/webrick/httpproxy.rb new file mode 100644 index 0000000..c84457e --- /dev/null +++ b/jni/ruby/sample/webrick/httpproxy.rb @@ -0,0 +1,25 @@ +require "webrick" +require "webrick/httpproxy" + +# The :ProxyContentHandler proc will be invoked before sending a response to +# the User-Agent. You can inspect the pair of request and response messages +# (or edit the response message if necessary). + +pch = Proc.new{|req, res| + p [ req.request_line, res.status_line ] +} + +def upstream_proxy + if prx = ENV["http_proxy"] + return URI.parse(prx) + end + return nil +end + +httpd = WEBrick::HTTPProxyServer.new( + :Port => 10080, + :ProxyContentHandler => pch, + :ProxyURI => upstream_proxy +) +Signal.trap(:INT){ httpd.shutdown } +httpd.start -- cgit v1.2.3