From 2ef439f7e4c62df9aad456d88d0e44f07a0bcf58 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sun, 13 Apr 2014 21:26:21 -0700 Subject: [PATCH] Add Content-Type for xml decoding --- src/Curl.class.php | 3 ++- tests/PHPCurlClass/PHPCurlClassTest.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Curl.class.php b/src/Curl.class.php index b0346ba..9624dfb 100644 --- a/src/Curl.class.php +++ b/src/Curl.class.php @@ -350,7 +350,8 @@ class Curl if (!is_null($json_obj)) { $ch->response = $json_obj; } - } elseif (preg_match('/^application\/xml/i', $ch->response_headers['Content-Type']) || + } elseif (preg_match('/^application\/rss\+xml/i', $ch->response_headers['Content-Type']) || + preg_match('/^application\/xml/i', $ch->response_headers['Content-Type']) || preg_match('/^text\/xml/i', $ch->response_headers['Content-Type'])) { $xml_obj = @simplexml_load_string($ch->response); if (!($xml_obj === false)) { diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 76317f7..b8adda3 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -432,6 +432,12 @@ class CurlTest extends PHPUnit_Framework_TestCase { PHPUnit_Framework_Assert::assertInstanceOf('SimpleXMLElement', $test->curl->response); } + xml_assertion('Content-Type', 'application/rss+xml; charset=utf-8'); + xml_assertion('content-type', 'application/rss+xml; charset=utf-8'); + xml_assertion('Content-Type', 'application/rss+xml'); + xml_assertion('content-type', 'application/rss+xml'); + xml_assertion('CONTENT-TYPE', 'application/rss+xml'); + xml_assertion('CONTENT-TYPE', 'application/rss+xml'); xml_assertion('Content-Type', 'application/xml; charset=utf-8'); xml_assertion('content-type', 'application/xml; charset=utf-8'); xml_assertion('Content-Type', 'application/xml');