I am developing some Request with Symfony to get an SSL Report from SSLLabs.
Problem: If I send this Request, I get a Response and check one Parameter. There are three Options for this Parameter ("ERROR", "IN_PROGRESS", "READY") which I have to handle.
public function getSSLReport(string $request)
{
try{
$result = null;
$httpClient = new \GuzzleHttp\Client();
$response = $httpClient->request('GET', 'https://api.ssllabs.com/api/v3/analyze?host='.$request.'&all=on');
$result = json_decode($response->getBody()->getContents(), true);
if($result['status'] == "READY") {
return new JsonResponse($result);
} else if($result['status'] == "ERROR") {
return new JsonResponse($result['statusMessage']);
} else {
$this->getSSLReport($request);
}
}catch (\Exception $ex)
{
return new JsonResponse($ex);
}
}
I am using some Recursion to call this Method again if the $result is IN_PROGRESS. But the Request is Pending all the Time, and canceled after 30 seconds.
If I get some Response where "status" == "READY" it works fine.
Add
sleepto wait for a couple of seconds:What I've changed:
elseand replacedelseifbyif.==by====.