2011-02-14 48 views

回答

1

我有同样的问题,并通过创建我自己的自定义WEBrick :: HTTPProxyServer并在其中添加put方法来得到它的工作。

require "webrick" 
require "webrick/httpproxy" 
require 'cgi' 

class CustomWEBrickProxyServer < WEBrick::HTTPProxyServer 

    def do_PUT(req, res) 
    perform_proxy_request(req, res) do |http, path, header| 
     http.put(path, req.body || "", header) 
    end 
    end 

    # This method is not needed for PUT but I added for completeness 
    def do_OPTIONS(req, res) 
    res['allow'] = "GET,HEAD,POST,OPTIONS,CONNECT,PUT" 
    end 

end 

然后,您需要使用您自己的自定义类启动代理服务器。

my_proxy_server = CustomWEBrickProxyServer.new :Port=> proxy_port, 
               :ProxyVia => forward_proxy, 
               :ProxyURI => forward_proxy, 
               :RequestCallback => method(:request_callback), 
               :ProxyContentHandler => method(:response_callback), 
               :AccessLog => method(:access_log)