aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authortuscanhobbit <tuscanhobbit@users.noreply.github.com>2014-09-22 22:44:10 +0200
committertuscanhobbit <tuscanhobbit@users.noreply.github.com>2014-09-22 22:44:10 +0200
commit6a9e8fcd20c0101d448061fdbf51034ab456d2c3 (patch)
tree08e4a6d051636b90a98a6889a0b677a7d7049982 /include/network.php
parented7f3001c1c1deec5076ae12114e5c42865b6251 (diff)
parent2070dbfdeace4a902208e9dfb50d950647142e99 (diff)
downloadvolse-hubzilla-6a9e8fcd20c0101d448061fdbf51034ab456d2c3.tar.gz
volse-hubzilla-6a9e8fcd20c0101d448061fdbf51034ab456d2c3.tar.bz2
volse-hubzilla-6a9e8fcd20c0101d448061fdbf51034ab456d2c3.zip
Merge from upstream
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/include/network.php b/include/network.php
index 0191f203d..7286f0b12 100644
--- a/include/network.php
+++ b/include/network.php
@@ -38,6 +38,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
return false;
@curl_setopt($ch, CURLOPT_HEADER, true);
+ @curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@@ -47,11 +48,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
- if (x($opts,'accept_content')){
- @curl_setopt($ch,CURLOPT_HTTPHEADER, array (
- "Accept: " . $opts['accept_content']
- ));
- }
+ if(x($opts,'headers'))
+ @curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
if(x($opts,'timeout') && intval($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
@@ -126,6 +124,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
}
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+
+ if(x($opts,'debug')) {
+ $ret['debug'] = $curl_info;
+ }
@curl_close($ch);
return($ret);
@@ -166,6 +168,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
return ret;
@curl_setopt($ch, CURLOPT_HEADER, true);
+ @curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_POST,1);
@@ -176,12 +179,6 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
-
- if (x($opts,'accept_content')){
- @curl_setopt($ch,CURLOPT_HTTPHEADER, array (
- "Accept: " . $opts['accept_content']
- ));
- }
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
@@ -258,11 +255,24 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+
+ if(x($opts,'debug')) {
+ $ret['debug'] = $curl_info;
+ }
+
+
curl_close($ch);
return($ret);
}
+function z_post_url_json($url,$params,$redirects = 0, $opts = array()) {
+
+ $opts = array_merge($opts,array('headers' => array('Content-Type: application/json')));
+ return z_post_url($url,json_encode($params),$redirects,$opts);
+
+}
+
function json_return_and_die($x) {
header("content-type: application/json");