trait RequestHelperTrait in Simple OAuth (OAuth2) & OpenID Connect 8.2
Same name and namespace in other branches
- 8.4 tests/src/Functional/RequestHelperTrait.php \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait
- 8.3 tests/src/Functional/RequestHelperTrait.php \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait
- 5.x tests/src/Functional/RequestHelperTrait.php \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait
Hierarchy
- trait \Drupal\Tests\simple_oauth\Functional\RequestHelperTrait
1 file declares its use of RequestHelperTrait
- RolesNegotiationFunctionalTest.php in simple_oauth_extras/
tests/ src/ Functional/ RolesNegotiationFunctionalTest.php
File
- tests/
src/ Functional/ RequestHelperTrait.php, line 10
Namespace
Drupal\Tests\simple_oauth\FunctionalView source
trait RequestHelperTrait {
/**
* Performs a HTTP request. Wraps the Guzzle HTTP client.
*
* Why wrap the Guzzle HTTP client? Because any error response is returned via
* an exception, which would make the tests unnecessarily complex to read.
*
* @param string $method
* HTTP method.
* @param \Drupal\Core\Url $url
* URL to request.
* @param array $request_options
* Request options to apply.
*
* @return \Psr\Http\Message\ResponseInterface
* The response
*
* @see \GuzzleHttp\ClientInterface::request()
*/
protected function request($method, Url $url, array $request_options) {
try {
$response = $this->httpClient
->request($method, $url
->toString(), $request_options);
} catch (ClientException $e) {
$response = $e
->getResponse();
} catch (ServerException $e) {
$response = $e
->getResponse();
} catch (RequestException $e) {
$response = $e
->getResponse();
}
return $response;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RequestHelperTrait:: |
protected | function | Performs a HTTP request. Wraps the Guzzle HTTP client. |