pipeline[] = $remoteGetRequest; } /** * Do a GET request to retrieve the contents of a remote URL. * * @param string $url URL to get. * @return Response Response for the executed request. * @throws FailedRemoteRequest If retrieving the contents from the URL failed. */ public function get($url) { foreach ($this->pipeline as $remoteGetRequest) { try { $response = $remoteGetRequest->get($url); if (! $response instanceof RemoteGetRequestResponse) { continue; } $statusCode = $response->getStatusCode(); if (200 <= $statusCode && $statusCode < 300) { return $response; } } catch (Exception $exception) { // Don't let exceptions bubble up, just continue with the next instance in the pipeline. } } // @todo Not sure what status code to use here. "503 Service Unavailable" is a temporary server-side error. return new RemoteGetRequestResponse('', [], 503); } }