/** * @dataProvider userAgentProvider */ public function testUserAgent($testAgent, $userAgent, $matches) { $_SERVER['HTTP_USER_AGENT'] = $testAgent; $this->assertEquals($matches, OC_Request::isUserAgent($userAgent)); }
/** * Sets the content disposition header (with possible workarounds) * @param string $filename file name * @param string $type disposition type, either 'attachment' or 'inline' */ public static function setContentDispositionHeader($filename, $type = 'attachment') { if (OC_Request::isUserAgent(array(OC_Request::USER_AGENT_IE, OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME, OC_Request::USER_AGENT_FREEBOX))) { header('Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode($filename) . '"'); } else { header('Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'); } }