Changeset 3350:7faafc3b6250 for inc
- Timestamp:
- 09/21/16 00:45:15 (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.update.php
r3349 r3350 104 104 { 105 105 $path = ''; 106 $client = netHttp::initClient($this->url,$path); 107 if ($client !== false) { 108 $client->setTimeout(4); 109 $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 110 $client->get($path); 111 $status = (int) $client->getStatus(); 112 113 if ($status >= 400) { 114 // If original URL uses HTTPS, try with HTTP 115 $url_parts = parse_url($client->getRequestURL()); 116 if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 117 118 // Replace https by http in url 119 $this->url = preg_replace('/^https(?=:\/\/)/i','http',$this->url); 120 121 $client = netHttp::initClient($this->url,$path); 122 if ($client !== false) { 123 $client->setTimeout(4); 124 $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 125 $client->get($path); 126 $status = (int) $client->getStatus(); 127 } 128 } 106 $status = 0; 107 108 $http_get = function ($http_url) use (&$status,$path) { 109 $client = netHttp::initClient($http_url,$path); 110 if ($client !== false) { 111 $client->setTimeout(4); 112 $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 113 $client->get($path); 114 $status = (int) $client->getStatus(); 129 115 } 130 131 if (!$status || $status >= 400) { 132 return; 116 return $client; 117 }; 118 119 $client = $http_get($this->url); 120 if ($status >= 400) { 121 // If original URL uses HTTPS, try with HTTP 122 $url_parts = parse_url($client->getRequestURL()); 123 if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 124 // Replace https by http in url 125 $this->url = preg_replace('/^https(?=:\/\/)/i','http',$this->url); 126 $client = $http_get($this->url); 133 127 } 134 $this->readVersion($client->getContent()); 135 } 136 } 137 catch (Exception $e) {} 128 } 129 if (!$status || $status >= 400) { 130 throw new Exception(); 131 } 132 $this->readVersion($client->getContent()); 133 } 134 catch (Exception $e) { 135 return; 136 } 138 137 139 138 # Create cache … … 224 223 try 225 224 { 226 $client = netHttp::initClient($url,$path); 227 $client->setTimeout(4); 228 $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 229 $client->useGzip(false); 230 $client->setPersistReferers(false); 231 $client->setOutput($dest); 232 $client->get($path); 233 $status = (int) $client->getStatus(); 234 235 if ($status >= 400) { 236 // If original URL uses HTTPS, try with HTTP 237 $url_parts = parse_url($client->getRequestURL()); 238 if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 239 240 // Replace https by http in url 241 $url = preg_replace('/^https(?=:\/\/)/i','http',$url); 242 243 $client = netHttp::initClient($url,$path); 225 $path = ''; 226 $status = 0; 227 228 $http_get = function ($http_url) use (&$status,$dest,$path) { 229 $client = netHttp::initClient($http_url,$path); 230 if ($client !== false) { 244 231 $client->setTimeout(4); 245 232 $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); … … 250 237 $status = (int) $client->getStatus(); 251 238 } 252 } 253 239 return $client; 240 }; 241 242 $client = $http_get($url); 243 if ($status >= 400) { 244 // If original URL uses HTTPS, try with HTTP 245 $url_parts = parse_url($client->getRequestURL()); 246 if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 247 // Replace https by http in url 248 $url = preg_replace('/^https(?=:\/\/)/i','http',$url); 249 $client = $http_get($url); 250 } 251 } 254 252 if ($status != 200) { 255 253 @unlink($dest);
Note: See TracChangeset
for help on using the changeset viewer.