Skip to content

Commit 34742ee

Browse files
committed
Decode atom+xml responses seamlessly
1 parent e632e1b commit 34742ee

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Curl.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ private function parseResponse($response)
309309
if (!is_null($json_obj)) {
310310
$response = $json_obj;
311311
}
312-
} elseif (preg_match('/^application\/rss\+xml/i', $response_headers['Content-Type']) ||
312+
} elseif (preg_match('/^application\/atom\+xml/i', $response_headers['Content-Type']) ||
313+
preg_match('/^application\/rss\+xml/i', $response_headers['Content-Type']) ||
313314
preg_match('/^application\/xml/i', $response_headers['Content-Type']) ||
314315
preg_match('/^text\/xml/i', $response_headers['Content-Type'])) {
315316
$xml_obj = @simplexml_load_string($response);

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ function xmlAssertion($key, $value)
574574
PHPUnit_Framework_Assert::assertInstanceOf('SimpleXMLElement', $test->curl->response);
575575
}
576576

577+
xmlAssertion('Content-Type', 'application/atom+xml; charset=UTF-8');
578+
xmlAssertion('Content-Type', 'application/atom+xml;charset=UTF-8');
577579
xmlAssertion('Content-Type', 'application/rss+xml');
578580
xmlAssertion('Content-Type', 'application/rss+xml; charset=utf-8');
579581
xmlAssertion('Content-Type', 'application/rss+xml;charset=utf-8');
@@ -584,6 +586,8 @@ function xmlAssertion($key, $value)
584586
xmlAssertion('Content-Type', 'text/xml; charset=utf-8');
585587
xmlAssertion('Content-Type', 'text/xml;charset=utf-8');
586588

589+
xmlAssertion('content-type', 'application/atom+xml; charset=UTF-8');
590+
xmlAssertion('content-type', 'application/atom+xml;charset=UTF-8');
587591
xmlAssertion('content-type', 'application/rss+xml');
588592
xmlAssertion('content-type', 'application/rss+xml; charset=utf-8');
589593
xmlAssertion('content-type', 'application/rss+xml;charset=utf-8');
@@ -594,6 +598,8 @@ function xmlAssertion($key, $value)
594598
xmlAssertion('content-type', 'text/xml; charset=utf-8');
595599
xmlAssertion('content-type', 'text/xml;charset=utf-8');
596600

601+
xmlAssertion('CONTENT-TYPE', 'application/atom+xml; charset=UTF-8');
602+
xmlAssertion('CONTENT-TYPE', 'application/atom+xml;charset=UTF-8');
597603
xmlAssertion('CONTENT-TYPE', 'application/rss+xml');
598604
xmlAssertion('CONTENT-TYPE', 'application/rss+xml; charset=utf-8');
599605
xmlAssertion('CONTENT-TYPE', 'application/rss+xml;charset=utf-8');

0 commit comments

Comments
 (0)