-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get responseTime() after sending request? #211
Comments
Save the request instance before passing it for execution. |
I will tell you what I'm trying to achieve. There is some problem in closing database after some timeout, so I should do the trick:
I want to do this after every request via HttpClient if the response time bigger than some value (for example, 15 seconds). |
$request = $client->get('http://test.com');
$response = $request->send();
$time = $request->requestTime();
if ($time > 2000) {
Yii::$app->db->close();
Yii::$app->db->open();
} |
But overall the problem sounds very weird as well as solution. I don't get how database re-connect is related to HTTP request time. |
What steps will reproduce the problem?
Send simple request, like $response = $client->get('http://test.com')->send();
What's expected?
I want to get total request time, like $response->requestTime();
What do you get instead?
Calling unknown method: yii\httpclient\Response::responseTime()
Additional info
$response also has no ability to get request object in which this method is present.
The text was updated successfully, but these errors were encountered: