Spaces:
Running
Running
souliya_pps
fix: re-add cache files as fallback, disable SSL verify in httpGet for HF container
060a0b2 Download app/Helpers/http.php from buddhaword/web: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/buddhaword/web/resolve/main/app/Helpers/http.php
- Command line
-
hf download hf://spaces/buddhaword/web/app/Helpers/http.php
-
curl -L -o http.php https://huggingface.co/spaces/buddhaword/web/resolve/main/app/Helpers/http.php
1.78 kB
| function httpGet($url, $timeout = 15) { | |
| if (function_exists('curl_init')) { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, [ | |
| CURLOPT_URL => $url, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_FOLLOWLOCATION => true, | |
| CURLOPT_MAXREDIRS => 3, | |
| CURLOPT_TIMEOUT => $timeout, | |
| CURLOPT_CONNECTTIMEOUT => $timeout, | |
| CURLOPT_SSL_VERIFYPEER => true, | |
| CURLOPT_USERAGENT => 'BuddhaWord/1.0', | |
| CURLOPT_HTTPGET => true, | |
| ]); | |
| $result = curl_exec($ch); | |
| $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| curl_close($ch); | |
| if ($result !== false && $httpCode >= 200 && $httpCode < 300) { | |
| return $result; | |
| } | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, [ | |
| CURLOPT_URL => $url, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_FOLLOWLOCATION => true, | |
| CURLOPT_MAXREDIRS => 3, | |
| CURLOPT_TIMEOUT => $timeout * 2, | |
| CURLOPT_CONNECTTIMEOUT => $timeout, | |
| CURLOPT_SSL_VERIFYPEER => false, | |
| CURLOPT_USERAGENT => 'BuddhaWord/1.0', | |
| CURLOPT_HTTPGET => true, | |
| ]); | |
| $result = curl_exec($ch); | |
| $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| curl_close($ch); | |
| if ($result !== false && $httpCode >= 200 && $httpCode < 300) { | |
| return $result; | |
| } | |
| } | |
| $context = stream_context_create([ | |
| 'http' => [ | |
| 'method' => 'GET', | |
| 'timeout' => $timeout, | |
| 'user_agent' => 'BuddhaWord/1.0', | |
| ], | |
| 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false], | |
| ]); | |
| return @file_get_contents($url, false, $context); | |
| } | |