mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
provide stream resource pointer option to z_fetch_url() and z_post_url() per earlier doco commit on syncing files/photos across clones.
This commit is contained in:
parent
6f6051f7e3
commit
fd07940b10
1 changed files with 13 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue