]> BookStack Code Mirror - bookstack/blob - app/Uploads/HttpFetcher.php
Added locale and text direction to html templates
[bookstack] / app / Uploads / HttpFetcher.php
1 <?php namespace BookStack\Uploads;
2
3 use BookStack\Exceptions\HttpFetchException;
4
5 class HttpFetcher
6 {
7
8     /**
9      * Fetch content from an external URI.
10      * @param string $uri
11      * @return bool|string
12      * @throws HttpFetchException
13      */
14     public function fetch(string $uri)
15     {
16         $ch = curl_init();
17         curl_setopt_array($ch, [
18             CURLOPT_URL => $uri,
19             CURLOPT_RETURNTRANSFER => 1,
20             CURLOPT_CONNECTTIMEOUT => 5
21         ]);
22
23         $data = curl_exec($ch);
24         $err = curl_error($ch);
25         curl_close($ch);
26
27         if ($err) {
28             throw new HttpFetchException($err);
29         }
30
31         return $data;
32     }
33 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.