【问题标题】:How to do a wiredump of XMLRPC::Client in ruby?如何在 ruby​​ 中执行 XMLRPC::Client 的连线转储?
【发布时间】:2010-11-18 19:41:28
【问题描述】:

我正在使用 ruby​​ 中的 XML RPC 编写一些代码,并且需要查看一些调试信息,你是如何做到的?

【问题讨论】:

    标签: xml ruby xml-rpc


    【解决方案1】:

    这里的答案很好,但请注意,http 级别的转储通常可能是 gzip 编码的,因此不太适合调试。另一种选择是使用client.http_last_response。例如:

    server = XMLRPC::Client.new2("http://rpc.technorati.com/rpc/ping")
    result = server.call("weblogUpdates.ping", "Copenhagen.rb", "http://www.copenhagenrb.dk/")
    puts server.http_last_response.body
    

    【讨论】:

      【解决方案2】:

      读取包的源代码,XMLRPC::Client 依次使用 Net::HTTP 作为其传输。

      所以我认为您应该能够相应地将方法修补到 XMLRPC::Client 中:

      require 'pp'
      
      # the magic happens here
      class XMLRPC::Client
        def set_debug
          @http.set_debug_output($stderr);
        end
      end
      
      server = XMLRPC::Client.new2("http://rpc.technorati.com/rpc/ping")
      server.set_debug
      result = server.call("weblogUpdates.ping", "Copenhagen.rb", "http://www.copenhagenrb.dk/")
      pp result
      

      (来自here 的 XMLRPC 示例)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-16
        • 1970-01-01
        • 2010-11-18
        • 2013-12-19
        • 1970-01-01
        • 1970-01-01
        • 2012-03-07
        • 2012-03-09
        相关资源
        最近更新 更多