File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -512,11 +512,17 @@ def do_rpc(request, async=false)
512512 # assume text/xml on instances where Content-Type header is not set
513513 ct_expected = resp [ "Content-Type" ] || 'text/xml'
514514 ct = parse_content_type ( ct_expected ) . first
515- if ct != "text/xml"
515+ case ct
516+ when "text/xml" , "application/xml"
517+ # OK
518+ else
519+ message =
520+ "Wrong content-type " +
521+ "(received '#{ ct } ' but expected 'text/xml' or 'application/xml')"
516522 if ct == "text/html"
517- raise "Wrong content-type (received ' #{ ct } ' but expected 'text/xml'): \n #{ data } "
523+ raise "#{ message } : \n #{ data } "
518524 else
519- raise "Wrong content-type (received ' #{ ct } ' but expected 'text/xml')"
525+ raise message
520526 end
521527 end
522528
Original file line number Diff line number Diff line change @@ -254,6 +254,28 @@ def test_async_request
254254 assert_equal expected , resp
255255 end
256256
257+ def test_application_xml_content_type
258+ fh = read 'blog.xml'
259+
260+ responses = {
261+ '/foo' => [ Fake ::Response . new ( fh , [ [ 'Content-Type' , 'application/xml' ] ] ) ]
262+ }
263+
264+ client = fake_client ( responses ) . new2 'http://example.org/foo'
265+
266+ resp = client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
267+
268+ expected = [ {
269+ "isAdmin" => true ,
270+ "url" => "http://tenderlovemaking.com/" ,
271+ "blogid" => "1" ,
272+ "blogName" => "Tender Lovemaking" ,
273+ "xmlrpc" => "http://tenderlovemaking.com/xmlrpc.php"
274+ } ]
275+
276+ assert_equal expected , resp
277+ end
278+
257279 # make a request without content-type header
258280 def test_bad_content_type
259281 fh = read 'blog.xml'
You can’t perform that action at this time.
0 commit comments