X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FHTTPRequest.php;h=74cf9cd0554d01a62beb0a1486b391bb734f4f69;hb=befc2af5043a3afde251721c0d27df695db1bb7e;hp=6442295273857e7af78df608b614f9e97e30fa22;hpb=a6fc9cd32e2e1f5873c53d7ddaabdbfb4a455795;p=friendica.git diff --git a/src/Network/HTTPRequest.php b/src/Network/HTTPRequest.php index 6442295273..74cf9cd055 100644 --- a/src/Network/HTTPRequest.php +++ b/src/Network/HTTPRequest.php @@ -1,6 +1,6 @@ baseUrl = $baseUrl->get(); } + /** {@inheritDoc} + * + * @throws HTTPException\InternalServerErrorException + */ + public function head(string $url, array $opts = []) + { + $opts['nobody'] = true; + + return $this->get($url, $opts); + } + /** * {@inheritDoc} * @@ -65,6 +76,7 @@ class HTTPRequest implements IHTTPRequest if (strlen($url) > 1000) { $this->logger->debug('URL is longer than 1000 characters.', ['url' => $url, 'callstack' => System::callstack(20)]); + $this->profiler->saveTimestamp($stamp1, 'network'); return CurlResult::createErrorCurl(substr($url, 0, 200)); } @@ -83,12 +95,14 @@ class HTTPRequest implements IHTTPRequest if (Network::isUrlBlocked($url)) { $this->logger->info('Domain is blocked.', ['url' => $url]); + $this->profiler->saveTimestamp($stamp1, 'network'); return CurlResult::createErrorCurl($url); } $ch = @curl_init($url); if (($redirects > 8) || (!$ch)) { + $this->profiler->saveTimestamp($stamp1, 'network'); return CurlResult::createErrorCurl($url); } @@ -130,6 +144,7 @@ class HTTPRequest implements IHTTPRequest curl_setopt($ch, CURLOPT_ENCODING, ''); if (!empty($opts['headers'])) { + $this->logger->notice('Wrong option \'headers\' used.'); @curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']); } @@ -172,8 +187,6 @@ class HTTPRequest implements IHTTPRequest curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } - $logger = $this->logger; - $s = @curl_exec($ch); $curl_info = @curl_getinfo($ch); @@ -191,6 +204,7 @@ class HTTPRequest implements IHTTPRequest $redirects++; $this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]); @curl_close($ch); + $this->profiler->saveTimestamp($stamp1, 'network'); return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects); } @@ -214,12 +228,14 @@ class HTTPRequest implements IHTTPRequest if (Network::isUrlBlocked($url)) { $this->logger->info('Domain is blocked.' . ['url' => $url]); + $this->profiler->saveTimestamp($stamp1, 'network'); return CurlResult::createErrorCurl($url); } $ch = curl_init($url); if (($redirects > 8) || (!$ch)) { + $this->profiler->saveTimestamp($stamp1, 'network'); return CurlResult::createErrorCurl($url); } @@ -279,6 +295,7 @@ class HTTPRequest implements IHTTPRequest $redirects++; $this->logger->info('Post redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]); curl_close($ch); + $this->profiler->saveTimestamp($stamp1, 'network'); return $this->post($curlResponse->getRedirectUrl(), $params, $headers, $redirects, $timeout); }