protected function AuthTest::basicAuthGet in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/rest/src/Tests/AuthTest.php \Drupal\rest\Tests\AuthTest::basicAuthGet()
Performs a HTTP request with Basic authentication.
We do not use \Drupal\simpletest\WebTestBase::drupalGet because we need to set curl settings for basic authentication.
Parameters
\Drupal\Core\Url $url: An Url object.
string $username: The user name to authenticate with.
string $password: The password.
string $mime_type: The MIME type for the Accept header.
Return value
string Curl output.
1 call to AuthTest::basicAuthGet()
- AuthTest::testRead in core/
modules/ rest/ src/ Tests/ AuthTest.php - Tests reading from an authenticated resource.
File
- core/
modules/ rest/ src/ Tests/ AuthTest.php, line 88 - Contains \Drupal\rest\Tests\AuthTest.
Class
- AuthTest
- Tests authentication provider restrictions.
Namespace
Drupal\rest\TestsCode
protected function basicAuthGet(Url $url, $username, $password, $mime_type = NULL) {
if (!isset($mime_type)) {
$mime_type = $this->defaultMimeType;
}
$out = $this
->curlExec(array(
CURLOPT_HTTPGET => TRUE,
CURLOPT_URL => $url
->setAbsolute()
->toString(),
CURLOPT_NOBODY => FALSE,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $username . ':' . $password,
CURLOPT_HTTPHEADER => array(
'Accept: ' . $mime_type,
),
));
$this
->verbose('GET request to: ' . $url
->toString() . '<hr />' . $out);
return $out;
}