[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    xmlrpc and charset=utf-8
From:       "Phil Tomson" <rubyfan () gmail ! com>
Date:       2006-04-17 23:42:52
Message-ID: d121f9aa0604171642q27a84444q2c771ef189e1a232 () mail ! gmail ! com
[Download RAW message or body]

I'm needed to interact with an XMLRPC server written using the
xmlrpc-c library for C/C++.  I was using Ruby 1.8.4 and found that I
could not get a simple xmlrpc client written in Ruby that would
communicate with the xmlrpc-c server.

I kept getting the following error:
  /usr/local/lib/ruby/1.8/xmlrpc/client.rb:547:in `do_rpc':
HTTP-Error: 400 Bad Request   (RuntimeError)
        from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
        from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
        from littleclient.rb:7


I tried downgrading to Ruby 1.8.2 and it worked fine.

When I investigated the difference I found the following in the
xmlrpc/client.rb file that comes with Ruby 1.8.4:
    def do_rpc(request, async=false)
      header = {
       "User-Agent"     =>  USER_AGENT,
       "Content-Type"   => "text/xml; charset=utf-8",
       "Content-Length" => request.size.to_s,
       "Connection"     => (async ? "close" : "keep-alive")
      }

This differs from the client.rb included with Ruby 1.8.2:

      def do_rpc(request, async=false)
        header = {
         "User-Agent"     =>  USER_AGENT,
         "Content-Type"   => "text/xml ",
         "Content-Length" => request.size.to_s,
         "Connection"     => (async ? "close" : "keep-alive")
        }

so I changed the code in the 1.8.4 version of client.rb to remove the
"charset=utf-8" - after that the ruby client interacted fine with the
xmlrpc-c server.

I'm wondering if utf-8 should be the default charset for Ruby's xmlrpc
client implementation?  Also, I'm wondering if perhaps it could be
selectable by adding an accessor method to the client to the Client
class?

Phil


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic