diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index c62cecfede5..ac6a86a305c 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -647,6 +647,7 @@ protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pa $uri['path'] = preg_replace('/^\//', null, $uri['path']); $uri['query'] = $this->_httpSerialize($uri['query']); + $uri['query'] = rtrim($uri['query'], '='); $stripIfEmpty = array( 'query' => '?%query', 'fragment' => '#%fragment', diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 20da9500911..2ed3c95a6f8 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -550,7 +550,7 @@ public function testRequest() { /** * Test the scheme + port keys - * + * * @return void */ public function testGetWithSchemeAndPort() { @@ -568,6 +568,26 @@ public function testGetWithSchemeAndPort() { $this->assertContains('Host: cakephp.org:8080', $this->Socket->request['header']); } +/** + * Test urls like http://cakephp.org/index.php?somestring without key/value pair for query + * + * @return void + */ + public function testRequestWithStringQuery() { + $this->Socket->reset(); + $request = array( + 'uri' => array( + 'scheme' => 'http', + 'host' => 'cakephp.org', + 'path' => 'index.php', + 'query' => 'somestring' + ), + 'method' => 'GET' + ); + $response = $this->Socket->request($request); + $this->assertContains("GET /index.php?somestring HTTP/1.1", $this->Socket->request['line']); + } + /** * The "*" asterisk character is only allowed for the following methods: OPTIONS. *