我正在使用 ruby 中的 XML RPC 编写一些代码,需要查看一些调试信息,你是怎么做的?
问问题
2048 次
2 回答
20
阅读包的源代码,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
(从这里获取的 XMLRPC 示例)。
于 2009-08-12T00:53:33.713 回答
0
很好的答案,但请注意,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
于 2016-06-01T08:35:12.937 回答