[ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
(no description)
File Size: | 906 lines (34 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
HTTPClient:: (19 methods):
__construct()
get()
dget()
post()
sendRequest()
ssltunnel()
sendData()
readData()
readLine()
debug()
debugHtml()
debugText()
parseHeaders()
buildHeaders()
getCookies()
postEncode()
postMultipartEncode()
uniqueConnectionId()
useProxyForUrl()
Class: HTTPClient - X-Ref
This class implements a basic HTTP client__construct() X-Ref |
Constructor. author: Andreas Gohr <andi@splitbrain.org> |
get($url, $sloppy304 = false) X-Ref |
Simple function to do a GET request Returns the wanted page or false on an error; return: false|string response body, false on error param: string $url The URL to fetch param: bool $sloppy304 Return body on 304 not modified author: Andreas Gohr <andi@splitbrain.org> |
dget($url, $data, $sloppy304 = false) X-Ref |
Simple function to do a GET request with given parameters Returns the wanted page or false on an error. This is a convenience wrapper around get(). The given parameters will be correctly encoded and added to the given base URL. return: false|string response body, false on error param: string $url The URL to fetch param: array $data Associative array of parameters param: bool $sloppy304 Return body on 304 not modified author: Andreas Gohr <andi@splitbrain.org> |
post($url, $data) X-Ref |
Simple function to do a POST request Returns the resulting page or false on an error; return: false|string response body, false on error param: string $url The URL to fetch param: array $data Associative array of parameters author: Andreas Gohr <andi@splitbrain.org> |
sendRequest($url, $data = '', $method = 'GET') X-Ref |
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. return: bool - true on success param: string $url - the complete URL param: mixed $data - the post data either as array or raw data param: string $method - HTTP Method usually GET or POST. author: Andreas Goetz <cpuidle@gmx.de> author: Andreas Gohr <andi@splitbrain.org> |
ssltunnel(&$socket, &$requesturl) X-Ref |
Tries to establish a CONNECT tunnel via Proxy Protocol, Servername and Port will be stripped from the request URL when a successful CONNECT happened return: bool true if a tunnel was established param: resource &$socket param: string &$requesturl |
sendData($socket, $data, $message) X-Ref |
Safely write data to a socket param: resource $socket An open socket handle param: string $data The data to write param: string $message Description of what is being read author: Tom N Harris <tnharris@whoopdedo.org> |
readData($socket, $nbytes, $message, $ignore_eof = false) X-Ref |
Safely read data from a socket Reads up to a given number of bytes or throws an exception if the response times out or ends prematurely. return: string param: resource $socket An open socket handle in non-blocking mode param: int $nbytes Number of bytes to read param: string $message Description of what is being read param: bool $ignore_eof End-of-file is not an error if this is set author: Tom N Harris <tnharris@whoopdedo.org> |
readLine($socket, $message) X-Ref |
Safely read a \n-terminated line from a socket Always returns a complete line, including the terminating \n. return: string param: resource $socket An open socket handle in non-blocking mode param: string $message Description of what is being read author: Tom N Harris <tnharris@whoopdedo.org> |
debug($info, $var = null) X-Ref |
print debug info Uses _debug_text or _debug_html depending on the SAPI name param: string $info param: mixed $var author: Andreas Gohr <andi@splitbrain.org> |
debugHtml($info, $var = null) X-Ref |
print debug info as HTML param: string $info param: mixed $var |
debugText($info, $var = null) X-Ref |
prints debug info as plain text param: string $info param: mixed $var |
parseHeaders($string) X-Ref |
convert given header string to Header array All Keys are lowercased. return: array param: string $string author: Andreas Gohr <andi@splitbrain.org> |
buildHeaders($headers) X-Ref |
convert given header array to header string return: string param: array $headers author: Andreas Gohr <andi@splitbrain.org> |
getCookies() X-Ref |
get cookies as http header string return: string author: Andreas Goetz <cpuidle@gmx.de> |
postEncode($data) X-Ref |
Encode data for posting return: string param: array $data author: Andreas Gohr <andi@splitbrain.org> |
postMultipartEncode($data) X-Ref |
Encode data for posting using multipart encoding return: string param: array $data author: Andreas Gohr <andi@splitbrain.org> |
uniqueConnectionId($server, $port) X-Ref |
Generates a unique identifier for a connection. return: string unique identifier param: string $server param: string $port |
useProxyForUrl($url) X-Ref |
Should the Proxy be used for the given URL? Checks the exceptions return: bool param: string $url |