diff options
author | redmatrix <git@macgirvin.com> | 2016-06-15 21:25:26 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-06-15 21:25:26 -0700 |
commit | d457f11717da40f44d98eeba5b88e6f1e5636247 (patch) | |
tree | e8c22b7ede0d3338e5dc8274e2401a66ea9cf324 /include | |
parent | bc5f73e6c32cebd2add7a36173404208e7140af3 (diff) | |
download | volse-hubzilla-d457f11717da40f44d98eeba5b88e6f1e5636247.tar.gz volse-hubzilla-d457f11717da40f44d98eeba5b88e6f1e5636247.tar.bz2 volse-hubzilla-d457f11717da40f44d98eeba5b88e6f1e5636247.zip |
custom request methods for curl
Diffstat (limited to 'include')
-rw-r--r-- | include/network.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/network.php b/include/network.php index 0dd10e29b..a595a03d1 100644 --- a/include/network.php +++ b/include/network.php @@ -21,15 +21,16 @@ function get_capath() { * TRUE if asked to return binary results (file download) * @param int $redirects default 0 * internal use, recursion counter - * @param array $opts (optional parameters) assoziative array with: + * @param array $opts (optional parameters) associative array with: * * \b accept_content => supply Accept: header with 'accept_content' as the value * * \b timeout => int seconds, default system config value or 60 seconds * * \b http_auth => username:password * * \b novalidate => do not validate SSL certs, default is to validate using our CA list * * \b nobody => only return the header * * \b filep => stream resource to write body to. header and body are not returned when using this option. + * * \b custom => custom request method: e.g. 'PUT', 'DELETE' * - * @return array an assoziative array with: + * @return array an associative array with: * * \e int \b return_code => HTTP return code or 0 if timeout or failure * * \e boolean \b success => boolean true (if HTTP 2xx result) or false * * \e string \b header => HTTP headers @@ -65,6 +66,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { if(x($opts,'nobody')) @curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']); + if(x($opts,'custom')) + @curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $opts['custom']); + if(x($opts,'timeout') && intval($opts['timeout'])) { @curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']); } @@ -165,7 +169,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { * 'http_auth' => username:password * 'novalidate' => do not validate SSL certs, default is to validate using our CA list * 'filep' => stream resource to write body to. header and body are not returned when using this option. - * @return array an assoziative array with: + * 'custom' => custom request method: e.g. 'PUT', 'DELETE' + * + * @return array an associative array with: * * \e int \b return_code => HTTP return code or 0 if timeout or failure * * \e boolean \b success => boolean true (if HTTP 2xx result) or false * * \e string \b header => HTTP headers @@ -205,6 +211,10 @@ logger('headers: ' . print_r($opts['headers'],true) . 'redir: ' . $redirects); if(x($opts,'nobody')) @curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']); + if(x($opts,'custom')) + @curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $opts['custom']); + + if(x($opts,'timeout') && intval($opts['timeout'])) { @curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']); } |