Merge pull request #9667 from annando/profiler-network

Store the network profiler data
This commit is contained in:
Hypolite Petovan 2020-12-17 08:24:09 -05:00 committed by GitHub
commit 61c1c1f530
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,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));
}
@ -94,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);
}
@ -201,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);
}
@ -224,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);
}
@ -289,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);
}