Fix #31: Combine multiple header fields into a comma-separated list

This commit is contained in:
Zach Borboa
2014-03-29 02:24:04 -07:00
parent 967181499a
commit 93350fe3a9
3 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -246,7 +246,8 @@ class Curl
list($key, $value) = explode(':', $raw_headers[$i], 2);
$key = trim($key);
$value = trim($value);
if (array_key_exists($key, $http_headers)) {
// Use isset() as array_key_exists() and ArrayAccess are not compatible.
if (isset($http_headers[$key])) {
$http_headers[$key] .= ',' . $value;
} else {
$http_headers[$key] = $value;
+6
View File
@@ -277,6 +277,12 @@ class CurlTest extends PHPUnit_Framework_TestCase {
$this->assertFalse(file_exists($cookie_file));
}
public function testMultipleCookieResponse() {
$test = new Test();
$test->server('multiple_cookie', 'GET');
$this->assertEquals($test->curl->response_headers['Set-Cookie'], 'cookie1=scrumptious,cookie2=mouthwatering');
}
public function testError() {
$test = new Test();
$test->curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 2000);
+5
View File
@@ -80,6 +80,11 @@ else if ($test === 'cookiejar') {
setcookie('mycookie', 'yum');
exit;
}
else if ($test === 'multiple_cookie') {
setcookie('cookie1', 'scrumptious');
setcookie('cookie2', 'mouthwatering');
exit;
}
else if ($test === 'response_header') {
header('Content-Type: application/json');
header('ETag: ' . md5('worldpeace'));