From 5537fd88dc60d76d6a85202f715aa1ef585281a9 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Thu, 1 Aug 2013 20:59:56 +0200 Subject: HTTPClient: Implement handling of two-dimensional data arrays --- inc/HTTPClient.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 0d7b80cf8..224b32982 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -808,8 +808,15 @@ class HTTPClient { function _postEncode($data){ $url = ''; foreach($data as $key => $val){ - if($url) $url .= '&'; - $url .= urlencode($key).'='.urlencode($val); + if (is_array($val)) { + foreach ($val as $k => $v) { + if($url) $url .= '&'; + $url .= urlencode($key).'['.$k.']='.urlencode($v); + } + } else { + if($url) $url .= '&'; + $url .= urlencode($key).'='.urlencode($val); + } } return $url; } -- cgit v1.2.3 From 4d4b1f8c22cf406b35a88c7299f8ee2bc033bf4d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 1 Aug 2013 22:08:23 +0200 Subject: use http_build_query() in HTTPClient this ensures nested POST data is correctly encoded --- inc/HTTPClient.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 224b32982..3964c8fbc 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -806,19 +806,7 @@ class HTTPClient { * @author Andreas Gohr */ function _postEncode($data){ - $url = ''; - foreach($data as $key => $val){ - if (is_array($val)) { - foreach ($val as $k => $v) { - if($url) $url .= '&'; - $url .= urlencode($key).'['.$k.']='.urlencode($v); - } - } else { - if($url) $url .= '&'; - $url .= urlencode($key).'='.urlencode($val); - } - } - return $url; + return http_build_query($data,'','&'); } /** -- cgit v1.2.3 From 5b230a45afb9bb825ba148e699bdcbfc57957fb4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 2 Aug 2013 13:44:33 +0200 Subject: HTTPClient don't pull too much bytes when no content-length is given --- inc/HTTPClient.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 3964c8fbc..b2621bdbb 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -463,6 +463,8 @@ class HTTPClient { } $r_body = $this->_readData($socket, $length, 'response (content-length limited)', true); + }elseif( !isset($this->resp_headers['transfer-encoding']) && $this->max_bodysize && !$this->keep_alive){ + $r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true); }else{ // read entire socket $r_size = 0; -- cgit v1.2.3 From f9fbe4cf2ef1298c185836461720fe1c88082118 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 20 Oct 2013 21:46:02 +0200 Subject: fix proxy CONNECT where HTTP 1.1 answer is given --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index b2621bdbb..96954fb47 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -553,7 +553,7 @@ class HTTPClient { }while($r_line != "\r\n" && $r_line != "\n"); $this->_debug('SSL Tunnel Response',$r_headers); - if(preg_match('/^HTTP\/1\.0 200/i',$r_headers)){ + if(preg_match('/^HTTP\/1\.[01] 200/i',$r_headers)){ if (stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)) { $requesturl = $requestinfo['path']; return true; -- cgit v1.2.3