public function HttpMimeTypeGuesserTest::dataHttpMimetypeGuessing in Remote Stream Wrapper 8
File
- tests/
src/ Kernel/ HttpMimeTypeGuesserTest.php, line 76
Class
- HttpMimeTypeGuesserTest
- @coversDefaultClass \Drupal\remote_stream_wrapper\File\MimeType\HttpMimeTypeGuesser @group remote_stream_wrapper
Namespace
Drupal\Tests\remote_stream_wrapper\KernelCode
public function dataHttpMimetypeGuessing() {
$data = [];
// Filename can be extracted from URL, no HTTP requests.
$data[] = [
'http://www.drupal.org/file.txt',
'text/plain',
];
// Test adding query strings and fragments which should be ignored.
$data[] = [
'http://www.drupal.org/test/file.txt?extension=.gif',
'text/plain',
];
$data[] = [
'https://www.drupal.org/FILE.PDF#foo',
'application/pdf',
];
// HTTP request sends a 405 Method Not Allowed on HEAD.
$data[] = [
'http://www.drupal.org/',
'html/get',
new ClientException(405, new Request('HEAD', ''), new Response(405)),
new Response(200, [
'Content-Type' => 'html/get',
]),
];
// HTTP request sends an empty HEAD response.
$data[] = [
'http://www.drupal.org/test',
'html/get',
new Response(200),
new Response(200, [
'Content-Type' => 'html/get',
]),
];
// HTTP request sends a valid HEAD response.
$data[] = [
'//www.drupal.org/test.unknown',
'html/head',
new Response(200, [
'Content-Type' => 'html/head',
]),
new Response(200, [
'Content-Type' => 'html/get',
]),
];
// Both HEAD and GET are error responses.
$data[] = [
'https://www.drupal.org/',
'application/octet-stream',
new ClientException(404, new Request('HEAD', ''), new Response(404)),
new ClientException(404, new Request('GET', ''), new Response(404)),
];
// Non-HTTP URLs should bypass the HTTP guesser.
$data[] = [
'public://test.unknown',
'application/octet-stream',
new Response(200, [
'Content-Type' => 'html/head',
]),
];
$data[] = [
'core/CHANGELOG.txt',
'text/plain',
new Response(200, [
'Content-Type' => 'html/head',
]),
];
return $data;
}