$this->baseUrl = $baseUrl->get();
}
+ /** {@inheritDoc}
+ *
+ * @throws HTTPException\InternalServerErrorException
+ */
+ public function head(string $url, array $opts = [])
+ {
+ $opts['nobody'] = true;
+
+ return $this->get($url, $opts);
+ }
+
/**
* {@inheritDoc}
*
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function get(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
+ public function get(string $url, array $opts = [], int &$redirects = 0)
{
$stamp1 = microtime(true);
curl_setopt($ch, CURLOPT_ENCODING, '');
if (!empty($opts['headers'])) {
+ $this->logger->notice('Wrong option \'headers\' used.');
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
}
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
- if ($binary) {
- @curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- }
-
- // don't let curl abort the entire application
- // if it throws any errors.
-
$s = @curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$redirects++;
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
@curl_close($ch);
- return $this->get($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
+ return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects);
}
@curl_close($ch);
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+ public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
- $ret = $this->fetchFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
+ $ret = $this->fetchFull($url, $timeout, $accept_content, $cookiejar, $redirects);
return $ret->getBody();
}
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+ public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
return $this->get(
$url,
- $binary,
[
'timeout' => $timeout,
'accept_content' => $accept_content,
DB_UPDATE_VERSION . '; ' .
$this->baseUrl;
}
-
- private function redirectBlocked(string $url = null)
- {
- $hosts = $this->config->get('system', 'no_redirect_hosts');
- if (empty($hosts)) {
- return false;
- }
-
- $hostlist = explode(',', $hosts);
- }
}