Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'feature/2774' into develop

Close #2774
Close #2745
  • Loading branch information...
commit 58dde5575aa7e5f63e47bb6bbb71ffab96d1dea6 2 parents c59ec4d + 7b3da41
@weierophinney weierophinney authored
View
32 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,33 @@ 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->config['argseparator'];
+ if (empty($argSeparator)) {
+ $argSeparator = ini_get('arg_separator.output');
+ $this->setArgSeparator($argSeparator);
+ }
+ return $argSeparator;
+ }
+
+ /**
* Set the encoding type and the boundary (if any)
*
* @param string $encType
@@ -773,14 +801,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;
}
View
42 tests/ZendTest/Http/Client/CommonHttpTests.php
@@ -113,20 +113,28 @@ protected function tearDown()
* Simple request tests
*/
+ public function methodProvider()
+ {
+ return array(
+ array(Request::METHOD_GET),
+ array(Request::METHOD_POST),
+ array(Request::METHOD_OPTIONS),
+ array(Request::METHOD_PUT),
+ array(Request::METHOD_DELETE),
+ array(Request::METHOD_PATCH),
+ );
+ }
+
/**
* Test simple requests
*
+ * @dataProvider methodProvider
*/
- public function testSimpleRequests()
+ public function testSimpleRequests($method)
{
- $methods= array(Request::METHOD_GET, Request::METHOD_POST, Request::METHOD_OPTIONS,
- Request::METHOD_PUT, Request::METHOD_DELETE, Request::METHOD_PATCH);
-
- foreach ($methods as $method) {
- $this->client->setMethod($method);
- $res = $this->client->send();
- $this->assertTrue($res->isSuccess(), "HTTP {$method} request failed.");
- }
+ $this->client->setMethod($method);
+ $res = $this->client->send();
+ $this->assertTrue($res->isSuccess(), "HTTP {$method} request failed.");
}
/**
@@ -978,6 +986,21 @@ public function testContentTypeAdditionlInfo($params)
}
/**
+ * @group 2774
+ * @group 2745
+ */
+ public function testUsesProvidedArgSeparator()
+ {
+ $this->client->setArgSeparator(';');
+ $request = new Request();
+ $request->setUri('http://framework.zend.com');
+ $request->setQuery(array('foo' => 'bar', 'baz' => 'bat'));
+ $this->client->send($request);
+ $rawRequest = $this->client->getLastRawRequest();
+ $this->assertContains('?foo=bar;baz=bat', $rawRequest);
+ }
+
+ /**
* Internal helpder function to get the contents of test files
*
* @param string $file
@@ -1045,5 +1068,4 @@ public static function invalidConfigProvider()
array(55)
);
}
-
}
View
22 tests/ZendTest/Http/ClientTest.php
@@ -79,4 +79,26 @@ public function testIfArrayIteratorOfHeadersCanBeSet()
$cookies = $client->getCookies();
$this->assertEquals(2, count($cookies));
}
+
+ /**
+ * @group 2774
+ * @group 2745
+ */
+ public function testArgSeparatorDefaultsToIniSetting()
+ {
+ $argSeparator = ini_get('arg_separator.output');
+ $client = new Client();
+ $this->assertEquals($argSeparator, $client->getArgSeparator());
+ }
+
+ /**
+ * @group 2774
+ * @group 2745
+ */
+ public function testCanOverrideArgSeparator()
+ {
+ $client = new Client();
+ $client->setArgSeparator(';');
+ $this->assertEquals(';', $client->getArgSeparator());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.