aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/network.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/network.php b/include/network.php
index c9ae8b283..ec255581d 100644
--- a/include/network.php
+++ b/include/network.php
@@ -27,11 +27,12 @@ function get_capath() {
* * \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.
*
* @return array an assoziative 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
+ * * \e string \b header => HTTP headers
* * \e string \b body => fetched content
*/
function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@@ -53,6 +54,11 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
+ if(x($opts,'filep')) {
+ @curl_setopt($ch, CURLOPT_FILE, $opts['filep']);
+ @curl_setopt($ch, CURLOPT_HEADER, $false);
+ }
+
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
@@ -158,6 +164,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
* 'timeout' => int seconds, default system config value or 60 seconds
* '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:
* * \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
@@ -185,6 +192,11 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
+ if(x($opts,'filep')) {
+ @curl_setopt($ch, CURLOPT_FILE, $opts['filep']);
+ @curl_setopt($ch, CURLOPT_HEADER, $false);
+ }
+
if(x($opts,'headers')) {
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
logger('headers: ' . print_r($opts['headers'],true) . 'redir: ' . $redirects);