|
|
@@ -298,7 +298,7 @@ class HttpSocket extends CakeSocket {
|
|
|
$this->request['auth'] = $this->_auth;
|
|
|
|
|
|
if (is_array($this->request['body'])) {
|
|
|
- $this->request['body'] = $this->_httpSerialize($this->request['body']);
|
|
|
+ $this->request['body'] = http_build_query($this->request['body']);
|
|
|
}
|
|
|
|
|
|
if (!empty($this->request['body']) && !isset($this->request['header']['Content-Type'])) {
|
|
|
@@ -623,7 +623,7 @@ class HttpSocket extends CakeSocket {
|
|
|
}
|
|
|
|
|
|
$uri['path'] = preg_replace('/^\//', null, $uri['path']);
|
|
|
- $uri['query'] = $this->_httpSerialize($uri['query']);
|
|
|
+ $uri['query'] = http_build_query($uri['query']);
|
|
|
$stripIfEmpty = array(
|
|
|
'query' => '?%query',
|
|
|
'fragment' => '#%fragment',
|
|
|
@@ -728,49 +728,7 @@ class HttpSocket extends CakeSocket {
|
|
|
if (is_array($query)) {
|
|
|
return $query;
|
|
|
}
|
|
|
- $parsedQuery = array();
|
|
|
-
|
|
|
- if (is_string($query) && !empty($query)) {
|
|
|
- $query = preg_replace('/^\?/', '', $query);
|
|
|
- $items = explode('&', $query);
|
|
|
-
|
|
|
- foreach ($items as $item) {
|
|
|
- if (strpos($item, '=') !== false) {
|
|
|
- list($key, $value) = explode('=', $item, 2);
|
|
|
- } else {
|
|
|
- $key = $item;
|
|
|
- $value = null;
|
|
|
- }
|
|
|
-
|
|
|
- $key = urldecode($key);
|
|
|
- $value = urldecode($value);
|
|
|
-
|
|
|
- if (preg_match_all('/\[([^\[\]]*)\]/iUs', $key, $matches)) {
|
|
|
- $subKeys = $matches[1];
|
|
|
- $rootKey = substr($key, 0, strpos($key, '['));
|
|
|
- if (!empty($rootKey)) {
|
|
|
- array_unshift($subKeys, $rootKey);
|
|
|
- }
|
|
|
- $queryNode =& $parsedQuery;
|
|
|
-
|
|
|
- foreach ($subKeys as $subKey) {
|
|
|
- if (!is_array($queryNode)) {
|
|
|
- $queryNode = array();
|
|
|
- }
|
|
|
-
|
|
|
- if ($subKey === '') {
|
|
|
- $queryNode[] = array();
|
|
|
- end($queryNode);
|
|
|
- $subKey = key($queryNode);
|
|
|
- }
|
|
|
- $queryNode =& $queryNode[$subKey];
|
|
|
- }
|
|
|
- $queryNode = $value;
|
|
|
- } else {
|
|
|
- $parsedQuery[$key] = $value;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ parse_str(ltrim($query, '?'), $parsedQuery);
|
|
|
return $parsedQuery;
|
|
|
}
|
|
|
|
|
|
@@ -812,22 +770,6 @@ class HttpSocket extends CakeSocket {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Serializes an array for transport.
|
|
|
- *
|
|
|
- * @param array $data Data to serialize
|
|
|
- * @return string Serialized variable
|
|
|
- */
|
|
|
- protected function _httpSerialize($data = array()) {
|
|
|
- if (is_string($data)) {
|
|
|
- return $data;
|
|
|
- }
|
|
|
- if (empty($data) || !is_array($data)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return substr(Router::queryString($data), 1);
|
|
|
- }
|
|
|
-
|
|
|
-/**
|
|
|
* Builds the header.
|
|
|
*
|
|
|
* @param array $header Header to build
|