Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

2 participants

@demonkoryu

This fixes #2745 (generate proper query strings when arg_separator.output is set to e.g. &).

@demonkoryu

That build failure is not my fault...

@weierophinney

I think a better approach would be to allow specifying the character to use for the arg separator. Right now, the issue you're addressing is specific to your implementation -- and that may be true for other users. Some might use ";" or "+" for argument separation, and this change would not help them in the least.

Would you be interested in helping make that happen? It'd be an additional option to pass to the client, and we'd read that option and use it in this location. If the option is not provided, we'd default to the php.ini setting.

@demonkoryu

Will do. I'll post another PR tomorrow.
Config option argseparator, perhaps?

@weierophinney

@demonkoryu You can push the changes to the same branch, and they'll show up in this PR.

And yes -- argseparator and/or arg_separator.

@weierophinney weierophinney was assigned
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#2774] Provided unit tests
- Tested default argument separator
- Tested that argument separator may be provided
- Provided functional test indicating provided argument separator is
  used
7b3da41
@weierophinney

I added unit tests, and fixed an issue in the process. Merged against develop branch, as it introduces a new method into the API; will release with 2.1.

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#2774] Provided unit tests
- Tested default argument separator
- Tested that argument separator may be provided
- Provided functional test indicating provided argument separator is
  used
beeaa75
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/2774' into develop
Close #2774
Close #2745
8387c06
@weierophinney weierophinney referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@weierophinney weierophinney referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-http
@weierophinney weierophinney [zendframework/zf2#2774] Provided unit tests
- Tested default argument separator
- Tested that argument separator may be provided
- Provided functional test indicating provided argument separator is
  used
f990979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2012
  1. @demonkoryu

    Fixes #2745.

    demonkoryu authored
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 2 deletions.
  1. +29 −2 library/Zend/Http/Client.php
View
31 library/Zend/Http/Client.php
@@ -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;
}
Something went wrong with that request. Please try again.