From 059c03b9d791c26ea3cff32f6aed5c046d2640cc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 27 Feb 2008 22:54:08 +0100 Subject: use DokuHTTPClient in XMLRPC library The code should work but is completely untested because it is currently not used. darcs-hash:20080227215408-7ad00-952ebba433991bde0c4282beeb4887c637eb25aa.gz --- inc/HTTPClient.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index e34027d02..d40a7b4db 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -139,8 +139,18 @@ class HTTPClient { } /** - * Do an HTTP request + * Send an HTTP request * + * This method handles the whole HTTP communication. It respects set proxy settings, + * builds the request headers, follows redirects and parses the response. + * + * Post data should be passed as associative array. When passed as string it will be + * sent as is. You will need to setup your own Content-Type header then. + * + * @param string $url - the complete URL + * @param mixed $data - the post data + * @param string $method - HTTP Method usually GET or POST. + * @return bool - true on success * @author Andreas Goetz * @author Andreas Gohr */ @@ -181,9 +191,12 @@ class HTTPClient { $headers['Referer'] = $this->referer; $headers['Connection'] = 'Close'; if($method == 'POST'){ - $post = $this->_postEncode($data); - $headers['Content-Type'] = 'application/x-www-form-urlencoded'; - $headers['Content-Length'] = strlen($post); + if(is_array($data)){ + $headers['Content-Type'] = 'application/x-www-form-urlencoded'; + $data = $this->_postEncode($data); + } + $headers['Content-Length'] = strlen($data); + $rmethod = 'POST'; } if($this->user) { $headers['Authorization'] = 'Basic '.base64_encode($this->user.':'.$this->pass); @@ -210,7 +223,7 @@ class HTTPClient { $request .= $this->_buildHeaders($headers); $request .= $this->_getCookies(); $request .= HTTP_NL; - $request .= $post; + $request .= $data; $this->_debug('request',$request); -- cgit v1.2.3