]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
Merge pull request #3213 from Hypolite/issue/#2792-2
[friendica.git] / include / network.php
index 727d5e57ecf68390145a0c49a9d2e52439b1b94d..b0e71fab7f8b93ecbc520c9af4e14e05c713992d 100644 (file)
@@ -118,7 +118,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
 
        $check_cert = get_config('system','verifyssl');
        @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
-       @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, (($check_cert) ? 2 : false));
+       if ($check_cert) {
+               @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
+       }
 
        $prx = get_config('system','proxy');
        if(strlen($prx)) {
@@ -141,6 +143,8 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
                logger('fetch_url error fetching '.$url.': '.curl_error($ch), LOGGER_NORMAL);
        }
 
+       $ret['errno'] = curl_errno($ch);
+
        $base = $s;
        $curl_info = @curl_getinfo($ch);
 
@@ -265,7 +269,9 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
 
        $check_cert = get_config('system','verifyssl');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
-       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, (($check_cert) ? 2 : false));
+       if ($check_cert) {
+               @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
+       }
        $prx = get_config('system','proxy');
        if(strlen($prx)) {
                curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
@@ -721,12 +727,14 @@ function strip_tracking_query_params($url)
  * This function strips tracking query params and follows redirections, either
  * through HTTP code or meta refresh tags. Stops after 10 redirections.
  *
+ * @todo Remove the $fetchbody parameter that generates an extraneous HEAD request
+ *
  * @see ParseUrl::getSiteinfo
  *
- * @param string $url
- * @param int $depth
- * @param bool $fetchbody
- * @return string
+ * @param string $url A user-submitted URL
+ * @param int $depth The current redirection recursion level (internal)
+ * @param bool $fetchbody Wether to fetch the body or not after the HEAD requests
+ * @return string A canonical URL
  */
 function original_url($url, $depth = 1, $fetchbody = false) {
        $a = get_app();