Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions library/Zend/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Client implements Stdlib\DispatchableInterface
'keepalive' => false,
'outputstream' => false,
'encodecookies' => true,
'argseparator' => null,
'rfc3986strict' => false
);

Expand Down Expand Up @@ -355,6 +356,32 @@ public function getMethod()
return $this->getRequest()->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)
*
Expand Down Expand Up @@ -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;
}
Expand Down