public function testConfigVary()
 {
     $body = "<html><head></head><body><h1>Mysite</h1></body></html>";
     $response = new HTTPResponse($body, 200);
     Director::config()->update('environment_type', 'live');
     HTTP::set_cache_age(30);
     HTTP::add_cache_headers($response);
     $v = $response->getHeader('Vary');
     $this->assertNotEmpty($v);
     $this->assertContains("Cookie", $v);
     $this->assertContains("X-Forwarded-Protocol", $v);
     $this->assertContains("User-Agent", $v);
     $this->assertContains("Accept", $v);
     HTTP::config()->update('vary', '');
     $response = new HTTPResponse($body, 200);
     HTTP::add_cache_headers($response);
     $v = $response->getHeader('Vary');
     $this->assertEmpty($v);
 }
 /**
  * Get the MIME type based on a file's extension. If the finfo class exists in PHP, and the file
  * exists relative to the project root, then use that extension, otherwise fallback to a list of
  * commonly known MIME types.
  *
  * @param string $filename
  *
  * @return string
  */
 public static function get_mime_type($filename)
 {
     // If the finfo module is compiled into PHP, use it.
     $path = BASE_PATH . DIRECTORY_SEPARATOR . $filename;
     if (class_exists('finfo') && file_exists($path)) {
         $finfo = new finfo(FILEINFO_MIME_TYPE);
         return $finfo->file($path);
     }
     // Fallback to use the list from the HTTP.yml configuration and rely on the file extension
     // to get the file mime-type
     $ext = File::get_file_extension($filename);
     // Get the mime-types
     $mimeTypes = HTTP::config()->get('MimeTypes');
     // The mime type doesn't exist
     if (!isset($mimeTypes[$ext])) {
         return 'application/unknown';
     }
     return $mimeTypes[$ext];
 }