XMLRPCで "`split' called for nil:NilClass" エラー
ruby1.8のXMLRPCで巨大なstring戻り値を受け取るときに
エラーが出力されるようになった。
Message: <"private method `split' called for nil:NilClass">
http://www.ruby-forum.com/topic/104425によると、lib/xmlprc/client.rb のバグらしい。
--- lib/xmlrpc/client.rb (revision 12167) +++ lib/xmlrpc/client.rb (working copy) @@ -546,15 +546,17 @@ module XMLRPC raise "HTTP-Error: #{resp.code} #{resp.message}" end - ct = parse_content_type(resp["Content-Type"]).first - if ct != "text/xml" - if ct == "text/html" - raise "Wrong content-type: \n#{data}" - else - raise "Wrong content-type" + unless resp["Content-Type"].nil? + ct = parse_content_type(resp["Content-Type"]).first + if ct != "text/xml" + if ct == "text/html" + raise "Wrong content-type: \n#{data}" + else + raise "Wrong content-type" + end end end - + expected = resp["Content-Length"] || "<unknown>" if data.nil? or data.size == 0 raise "Wrong size. Was #{data.size}, should be #{expected}"
しかし、ライブラリを修正するのも気が引けるので、戻り値のstringを分割して、複数回に分けて受け取るように修正した。
もしかしたら、戻りstringのサイズが大きいときに content-type が抜け落ちるという、Lighthttpd側のバグなのかもしれない。。
→喉元過ぎたので、調査する気ゼロw