private static function follow_url($url)
 {
     if (!function_exists('curl_exec')) {
         return false;
     }
     $curl = curl_init();
     $curl_version = curl_version();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     // make curl_exec() return the result
     curl_setopt($curl, CURLOPT_HEADER, true);
     // header only
     curl_setopt($curl, CURLOPT_NOBODY, true);
     // return no body; HTTP request method: HEAD
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, \Podlove\get_setting('website', 'ssl_verify_peer') == 'on');
     // Don't check SSL certificate in order to be able to use self signed certificates
     curl_setopt($curl, CURLOPT_FAILONERROR, true);
     curl_setopt($curl, CURLOPT_TIMEOUT, 3);
     // HEAD requests shouldn't take > 2 seconds
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
     // follow redirects
     curl_setopt($curl, CURLOPT_MAXREDIRS, 0);
     // maximum number of redirects
     curl_setopt($curl, CURLOPT_USERAGENT, \Podlove\Http\Curl::user_agent());
     $response = curl_exec($curl);
     $response_header = curl_getinfo($curl);
     $error = curl_error($curl);
     curl_close($curl);
     if (isset($response_header['redirect_url']) && $response_header['redirect_url']) {
         return $response_header['redirect_url'];
     } else {
         return false;
     }
     // return array(
     // 	'header'   => $response_header,
     // 	'response' => $response,
     // 	'error'    => $error
     // );
 }
 public function check_code()
 {
     if (isset($_GET["code"]) && $_GET["code"]) {
         if ($this->get_module_option('auphonic_api_key') == "") {
             $ch = curl_init('https://auth.podlove.org/auphonic.php');
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
             curl_setopt($ch, CURLOPT_USERAGENT, \Podlove\Http\Curl::user_agent());
             curl_setopt($ch, CURLOPT_POSTFIELDS, array("redirect_uri" => get_site_url() . '/wp-admin/admin.php?page=podlove_settings_modules_handle', "code" => $_GET["code"]));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             // verify against startssl crt
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
             curl_setopt($ch, CURLOPT_CAINFO, \Podlove\PLUGIN_DIR . '/cert/podlove.crt');
             $result = curl_exec($ch);
             $this->update_module_option('auphonic_api_key', $result);
             header('Location: ' . get_site_url() . '/wp-admin/admin.php?page=podlove_settings_modules_handle');
         }
     }
     if (isset($_GET["reset_auphonic_auth_code"]) && $_GET["reset_auphonic_auth_code"] == "1") {
         $this->update_module_option('auphonic_api_key', "");
         delete_transient('podlove_auphonic_user');
         delete_transient('podlove_auphonic_presets');
         header('Location: ' . get_site_url() . '/wp-admin/admin.php?page=podlove_settings_modules_handle');
     }
 }
 /**
  * @todo  use \Podlove\Http\Curl
  * 
  * @return array	
  */
 public static function curl_get_header_for_url($url, $etag = NULL)
 {
     if (!function_exists('curl_exec')) {
         return [];
     }
     $curl = curl_init();
     if (\Podlove\Http\Curl::curl_can_follow_redirects()) {
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
         // follow redirects
         curl_setopt($curl, CURLOPT_MAXREDIRS, 5);
         // maximum number of redirects
     } else {
         $url = \Podlove\Http\Curl::resolve_redirects($url, 5);
     }
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     // make curl_exec() return the result
     curl_setopt($curl, CURLOPT_HEADER, true);
     // header only
     curl_setopt($curl, CURLOPT_NOBODY, true);
     // return no body; HTTP request method: HEAD
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, \Podlove\get_setting('website', 'ssl_verify_peer') == 'on');
     // Don't check SSL certificate in order to be able to use self signed certificates
     curl_setopt($curl, CURLOPT_FAILONERROR, true);
     curl_setopt($curl, CURLOPT_TIMEOUT, 3);
     // HEAD requests shouldn't take > 2 seconds
     if ($etag) {
         curl_setopt($curl, CURLOPT_HTTPHEADER, array('If-None-Match: "' . $etag . '"'));
     }
     curl_setopt($curl, CURLOPT_USERAGENT, \Podlove\Http\Curl::user_agent());
     $response = curl_exec($curl);
     $response_header = curl_getinfo($curl);
     $error = curl_error($curl);
     curl_close($curl);
     return array('header' => $response_header, 'response' => $response, 'error' => $error);
 }