diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-02-27 22:54:08 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-02-27 22:54:08 +0100 |
commit | 059c03b9d791c26ea3cff32f6aed5c046d2640cc (patch) | |
tree | e34b79dafa11406539bb8227751e6d48c5989d59 /inc/HTTPClient.php | |
parent | fdd2e9d64295969d5945f11cb7d457aa599a028f (diff) | |
download | rpg-059c03b9d791c26ea3cff32f6aed5c046d2640cc.tar.gz rpg-059c03b9d791c26ea3cff32f6aed5c046d2640cc.tar.bz2 |
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
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r-- | inc/HTTPClient.php | 23 |
1 files changed, 18 insertions, 5 deletions
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 <cpuidle@gmx.de> * @author Andreas Gohr <andi@splitbrain.org> */ @@ -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); |