зеркало из https://github.com/github/ruby.git
* 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:
Родитель
8029539d02
Коммит
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>
|
||||
|
||||
* 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}"
|
||||
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/html"
|
||||
raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
|
||||
|
|
|
@ -188,7 +188,7 @@ module XMLRPC
|
|||
rest.each { |x| refute x }
|
||||
end
|
||||
|
||||
def test_bad_content_type
|
||||
def test_request
|
||||
fh = read 'blog.xml'
|
||||
|
||||
responses = {
|
||||
|
@ -210,6 +210,29 @@ module XMLRPC
|
|||
assert_equal expected, resp
|
||||
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
|
||||
def read filename
|
||||
File.read File.expand_path(File.join(__FILE__, '..', 'data', filename))
|
||||
|
|
Загрузка…
Ссылка в новой задаче