Skip to content

Commit 96b3a61

Browse files
authored
Merge pull request php-curl-class#514 from zachborboa/master
Add support for detecting SOAP content-types
2 parents 932b869 + a969fab commit 96b3a61

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Curl/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Curl
5555

5656
private $jsonDecoderArgs = array();
5757
private $jsonPattern = '/^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i';
58-
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+)?)xml~i';
58+
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+|soap\+)?)xml~i';
5959
private $defaultDecoder = null;
6060

6161
public static $RFC2616 = array(

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,27 @@ public function testJsonContentTypeDetection()
25672567
}
25682568
}
25692569

2570+
public function testXmlContentTypeDetection()
2571+
{
2572+
$xml_content_types = array(
2573+
'application/atom+xml',
2574+
'application/rss+xml',
2575+
'application/soap+xml',
2576+
'application/xml',
2577+
'text/xml',
2578+
);
2579+
2580+
$class = new \ReflectionClass('\Curl\Curl');
2581+
$property = $class->getProperty('xmlPattern');
2582+
$property->setAccessible(true);
2583+
$xml_pattern = $property->getValue(new Curl);
2584+
2585+
foreach ($xml_content_types as $xml_content_type) {
2586+
$message = '"' . $xml_content_type . '" does not match pattern ' . $xml_pattern;
2587+
$this->assertEquals(1, preg_match($xml_pattern, $xml_content_type), $message);
2588+
}
2589+
}
2590+
25702591
public function testXMLResponse()
25712592
{
25722593
foreach (array(
@@ -2579,6 +2600,9 @@ public function testXMLResponse()
25792600
'application/rss+xml',
25802601
'application/rss+xml; charset=utf-8',
25812602
'application/rss+xml;charset=utf-8',
2603+
'application/soap+xml',
2604+
'application/soap+xml; charset=utf-8',
2605+
'application/soap+xml;charset=utf-8',
25822606
'application/xml',
25832607
'application/xml; charset=utf-8',
25842608
'application/xml;charset=utf-8',

0 commit comments

Comments
 (0)