Fixes #2745 (generate proper query strings). #2774

Closed
wants to merge 1 commit into
from
Jump to file
+29 −2
Split
@@ -113,6 +113,7 @@ class Client implements Stdlib\DispatchableInterface
'keepalive' => false,
'outputstream' => false,
'encodecookies' => true,
+ 'argseparator' => null,
'rfc3986strict' => false
);
@@ -356,6 +357,32 @@ public function getMethod()
}
/**
+ * Set the query string argument separator
+ *
+ * @param string $argSeparator
+ * @return Client
+ */
+ public function setArgSeparator($argSeparator)
+ {
+ $this->setOptions(array("argseparator" => $argSeparator));
+ return $this;
+ }
+
+ /**
+ * Get the query string argument separator
+ *
+ * @return string
+ */
+ public function getArgSeparator()
+ {
+ $argSeparator = $this->options['argseparator'];
+ if (empty($argSeparator)) {
+ $argSeparator = ini_get('arg_separator.output');
+ }
+ return $argSeparator;
+ }
+
+ /**
* Set the encoding type and the boundary (if any)
*
* @param string $encType
@@ -773,14 +800,14 @@ public function send(Request $request = null)
if (!empty($queryArray)) {
$newUri = $uri->toString();
- $queryString = http_build_query($query);
+ $queryString = http_build_query($query, null, $this->getArgSeparator());
if ($this->config['rfc3986strict']) {
$queryString = str_replace('+', '%20', $queryString);
}
if (strpos($newUri, '?') !== false) {
- $newUri .= '&' . $queryString;
+ $newUri .= $this->getArgSeparator() . $queryString;
} else {
$newUri .= '?' . $queryString;
}