* lib/xmlrpc/client.rb: assume servers that do not send a Content-Type
header are sending 'text/xml'. Thanks Nathan Leavitt! [ruby-core:41204] [Bug #5660] * test/xmlrpc/test_client.rb: supporting test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8029539d02
commit
9e9264c8d5
@ -1,3 +1,11 @@
|
|||||||
|
Wed Mar 7 07:43:29 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* lib/xmlrpc/client.rb: assume servers that do not send a Content-Type
|
||||||
|
header are sending 'text/xml'. Thanks Nathan Leavitt!
|
||||||
|
[ruby-core:41204] [Bug #5660]
|
||||||
|
|
||||||
|
* test/xmlrpc/test_client.rb: supporting test
|
||||||
|
|
||||||
Wed Mar 7 07:39:28 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
Wed Mar 7 07:39:28 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* test/xmlrpc/test_client.rb: adding a test for performing an XMLRPC
|
* test/xmlrpc/test_client.rb: adding a test for performing an XMLRPC
|
||||||
|
@ -556,7 +556,9 @@ module XMLRPC
|
|||||||
raise "HTTP-Error: #{resp.code} #{resp.message}"
|
raise "HTTP-Error: #{resp.code} #{resp.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
ct = parse_content_type(resp["Content-Type"]).first
|
# assume text/xml on instances where Content-Type header is not set
|
||||||
|
ct_expected = resp["Content-Type"] || 'text/xml'
|
||||||
|
ct = parse_content_type(ct_expected).first
|
||||||
if ct != "text/xml"
|
if ct != "text/xml"
|
||||||
if ct == "text/html"
|
if ct == "text/html"
|
||||||
raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
|
raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
|
||||||
|
@ -188,7 +188,7 @@ module XMLRPC
|
|||||||
rest.each { |x| refute x }
|
rest.each { |x| refute x }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bad_content_type
|
def test_request
|
||||||
fh = read 'blog.xml'
|
fh = read 'blog.xml'
|
||||||
|
|
||||||
responses = {
|
responses = {
|
||||||
@ -210,6 +210,29 @@ module XMLRPC
|
|||||||
assert_equal expected, resp
|
assert_equal expected, resp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# make a request without content-type header
|
||||||
|
def test_bad_content_type
|
||||||
|
fh = read 'blog.xml'
|
||||||
|
|
||||||
|
responses = {
|
||||||
|
'/foo' => [ Fake::Response.new(fh) ]
|
||||||
|
}
|
||||||
|
|
||||||
|
client = fake_client(responses).new2 'http://example.org/foo'
|
||||||
|
|
||||||
|
resp = client.call('wp.getUsersBlogs', 'tlo', 'omg')
|
||||||
|
|
||||||
|
expected = [{
|
||||||
|
"isAdmin" => true,
|
||||||
|
"url" => "http://tenderlovemaking.com/",
|
||||||
|
"blogid" => "1",
|
||||||
|
"blogName" => "Tender Lovemaking",
|
||||||
|
"xmlrpc" => "http://tenderlovemaking.com/xmlrpc.php"
|
||||||
|
}]
|
||||||
|
|
||||||
|
assert_equal expected, resp
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def read filename
|
def read filename
|
||||||
File.read File.expand_path(File.join(__FILE__, '..', 'data', filename))
|
File.read File.expand_path(File.join(__FILE__, '..', 'data', filename))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user