Merge pull request #514 from zachborboa/master

Add support for detecting SOAP content-types
This commit is contained in:
Zach Borboa
2018-04-26 18:14:26 -07:00
committed by GitHub
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ class Curl
private $jsonDecoderArgs = array();
private $jsonPattern = '/^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i';
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+)?)xml~i';
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+|soap\+)?)xml~i';
private $defaultDecoder = null;
public static $RFC2616 = array(
+24
View File
@@ -2567,6 +2567,27 @@ class CurlTest extends \PHPUnit\Framework\TestCase
}
}
public function testXmlContentTypeDetection()
{
$xml_content_types = array(
'application/atom+xml',
'application/rss+xml',
'application/soap+xml',
'application/xml',
'text/xml',
);
$class = new \ReflectionClass('\Curl\Curl');
$property = $class->getProperty('xmlPattern');
$property->setAccessible(true);
$xml_pattern = $property->getValue(new Curl);
foreach ($xml_content_types as $xml_content_type) {
$message = '"' . $xml_content_type . '" does not match pattern ' . $xml_pattern;
$this->assertEquals(1, preg_match($xml_pattern, $xml_content_type), $message);
}
}
public function testXMLResponse()
{
foreach (array(
@@ -2579,6 +2600,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase
'application/rss+xml',
'application/rss+xml; charset=utf-8',
'application/rss+xml;charset=utf-8',
'application/soap+xml',
'application/soap+xml; charset=utf-8',
'application/soap+xml;charset=utf-8',
'application/xml',
'application/xml; charset=utf-8',
'application/xml;charset=utf-8',