|
5 | 5 | * @link http://github.com/zendframework/zf2 for the canonical source repository |
6 | 6 | * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) |
7 | 7 | * @license http://framework.zend.com/license/new-bsd New BSD License |
8 | | - * @package Zend_Http |
9 | 8 | */ |
10 | 9 |
|
11 | 10 | namespace Zend\Http; |
|
19 | 18 |
|
20 | 19 | /** |
21 | 20 | * Http client |
22 | | - * |
23 | | - * @category Zend |
24 | | - * @package Zend\Http |
25 | 21 | */ |
26 | 22 | class Client implements Stdlib\DispatchableInterface |
27 | 23 | { |
@@ -113,6 +109,7 @@ class Client implements Stdlib\DispatchableInterface |
113 | 109 | 'keepalive' => false, |
114 | 110 | 'outputstream' => false, |
115 | 111 | 'encodecookies' => true, |
| 112 | + 'argseparator' => null, |
116 | 113 | 'rfc3986strict' => false |
117 | 114 | ); |
118 | 115 |
|
@@ -355,6 +352,33 @@ public function getMethod() |
355 | 352 | return $this->getRequest()->getMethod(); |
356 | 353 | } |
357 | 354 |
|
| 355 | + /** |
| 356 | + * Set the query string argument separator |
| 357 | + * |
| 358 | + * @param string $argSeparator |
| 359 | + * @return Client |
| 360 | + */ |
| 361 | + public function setArgSeparator($argSeparator) |
| 362 | + { |
| 363 | + $this->setOptions(array("argseparator" => $argSeparator)); |
| 364 | + return $this; |
| 365 | + } |
| 366 | + |
| 367 | + /** |
| 368 | + * Get the query string argument separator |
| 369 | + * |
| 370 | + * @return string |
| 371 | + */ |
| 372 | + public function getArgSeparator() |
| 373 | + { |
| 374 | + $argSeparator = $this->config['argseparator']; |
| 375 | + if (empty($argSeparator)) { |
| 376 | + $argSeparator = ini_get('arg_separator.output'); |
| 377 | + $this->setArgSeparator($argSeparator); |
| 378 | + } |
| 379 | + return $argSeparator; |
| 380 | + } |
| 381 | + |
358 | 382 | /** |
359 | 383 | * Set the encoding type and the boundary (if any) |
360 | 384 | * |
@@ -469,11 +493,11 @@ public function addCookie($cookie, $value = null, $expire = null, $path = null, |
469 | 493 | throw new Exception\InvalidArgumentException('The cookie parameter is not a valid Set-Cookie type'); |
470 | 494 | } |
471 | 495 | } |
472 | | - } elseif ($cookie instanceof Header\SetCookie) { |
473 | | - $this->cookies[$this->getCookieId($cookie)] = $cookie; |
474 | 496 | } elseif (is_string($cookie) && $value !== null) { |
475 | 497 | $setCookie = new Header\SetCookie($cookie, $value, $expire, $path, $domain, $secure, $httponly, $maxAge, $version); |
476 | 498 | $this->cookies[$this->getCookieId($setCookie)] = $setCookie; |
| 499 | + } elseif ($cookie instanceof Header\SetCookie) { |
| 500 | + $this->cookies[$this->getCookieId($cookie)] = $cookie; |
477 | 501 | } else { |
478 | 502 | throw new Exception\InvalidArgumentException('Invalid parameter type passed as Cookie'); |
479 | 503 | } |
@@ -777,14 +801,14 @@ public function send(Request $request = null) |
777 | 801 |
|
778 | 802 | if (!empty($queryArray)) { |
779 | 803 | $newUri = $uri->toString(); |
780 | | - $queryString = http_build_query($query); |
| 804 | + $queryString = http_build_query($query, null, $this->getArgSeparator()); |
781 | 805 |
|
782 | 806 | if ($this->config['rfc3986strict']) { |
783 | 807 | $queryString = str_replace('+', '%20', $queryString); |
784 | 808 | } |
785 | 809 |
|
786 | 810 | if (strpos($newUri, '?') !== false) { |
787 | | - $newUri .= '&' . $queryString; |
| 811 | + $newUri .= $this->getArgSeparator() . $queryString; |
788 | 812 | } else { |
789 | 813 | $newUri .= '?' . $queryString; |
790 | 814 | } |
@@ -855,9 +879,9 @@ public function send(Request $request = null) |
855 | 879 | } |
856 | 880 |
|
857 | 881 | // Get the cookies from response (if any) |
858 | | - $setCookie = $response->getCookie(); |
859 | | - if (!empty($setCookie)) { |
860 | | - $this->addCookie($setCookie); |
| 882 | + $setCookies = $response->getCookie(); |
| 883 | + if (!empty($setCookies)) { |
| 884 | + $this->addCookie($setCookies); |
861 | 885 | } |
862 | 886 |
|
863 | 887 | // If we got redirected, look for the Location header |
@@ -1294,7 +1318,6 @@ protected function doRequest(Http $uri, $method, $secure = false, $headers = arr |
1294 | 1318 | throw new Exception\RuntimeException('Adapter does not support streaming'); |
1295 | 1319 | } |
1296 | 1320 | } |
1297 | | - |
1298 | 1321 | // HTTP connection |
1299 | 1322 | $this->lastRawRequest = $this->adapter->write($method, |
1300 | 1323 | $uri, $this->config['httpversion'], $headers, $body); |
|
0 commit comments