Skip to content
Permalink
Browse files

Changin how HttpSocket parses query string parameters. Makes HttpSock…

…et querystring parameter parsing more congruent with how PHP handles query string parameters in that it doesn't require urlencoded characters.

Tests added.
Fixes #156
  • Loading branch information...
markstory committed Oct 30, 2009
1 parent a31a2d2 commit 17edec84607ad1a347113278bddc3eed988c5e21
Showing with 23 additions and 1 deletion.
  1. +1 −1 cake/libs/http_socket.php
  2. +22 −0 cake/tests/cases/libs/http_socket.test.php
@@ -672,7 +672,7 @@ function parseQuery($query) {
foreach ($items as $item) {
if (strpos($item, '=') !== false) {
list($key, $value) = explode('=', $item);
list($key, $value) = explode('=', $item, 2);
} else {
$key = $item;
$value = null;
@@ -878,6 +878,28 @@ function testParseUri() {
'host' => 'www.google.com',
'port' => 8080,
));
$uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1&param2=value2%3Dvalue3');
$this->assertIdentical($uri, array(
'scheme' => 'http',
'host' => 'www.cakephp.org',
'path' => '/',
'query' => array(
'param1' => 'value1',
'param2' => 'value2=value3'
)
));
$uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1&param2=value2=value3');
$this->assertIdentical($uri, array(
'scheme' => 'http',
'host' => 'www.cakephp.org',
'path' => '/',
'query' => array(
'param1' => 'value1',
'param2' => 'value2=value3'
)
));
}
/**
* Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's

0 comments on commit 17edec8

Please sign in to comment.
You can’t perform that action at this time.