$_SERVER['HTTP_SSL_HTTPS'] = 'ON'; $t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" environment variable'); $_SERVER['HTTP_SSL_HTTPS'] = 'on'; $t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" environment variable'); $_SERVER['HTTP_SSL_HTTPS'] = '1'; $t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" environment variable'); $request->resetPathInfoArray(); $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; $t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_X_FORWARDED_PROTO" environment variable'); $request->resetPathInfoArray(); // ->getUriPrefix() $t->diag('->getUriPrefix()'); $request->resetPathInfoArray(); $_SERVER['SERVER_PORT'] = '80'; $_SERVER['HTTP_HOST'] = 'symfony-project.org:80'; $t->is($request->getUriPrefix(), 'http://symfony-project.org', '->getUriPrefix() returns no port for standard http port'); $_SERVER['HTTP_HOST'] = 'symfony-project.org'; $t->is($request->getUriPrefix(), 'http://symfony-project.org', '->getUriPrefix() works fine with no port in HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'symfony-project.org:8088'; $t->is($request->getUriPrefix(), 'http://symfony-project.org:8088', '->getUriPrefix() works for nonstandard http ports'); $request->resetPathInfoArray(); $_SERVER['HTTPS'] = 'on'; $_SERVER['SERVER_PORT'] = '443'; $_SERVER['HTTP_HOST'] = 'symfony-project.org:443'; $t->is($request->getUriPrefix(), 'https://symfony-project.org', '->getUriPrefix() returns no port for standard https port'); $_SERVER['HTTP_HOST'] = 'symfony-project.org'; $t->is($request->getUriPrefix(), 'https://symfony-project.org', '->getUriPrefix() works fine with no port in HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'symfony-project.org:8043'; $t->is($request->getUriPrefix(), 'https://symfony-project.org:8043', '->getUriPrefix() works for nonstandard https ports'); $request->resetPathInfoArray(); $_SERVER['HTTP_HOST'] = 'symfony-project.org';
// ->getFormat() ->setFormat() $t->diag('->getFormat() ->setFormat()'); $request->setFormat('js', 'application/x-javascript'); $t->is($request->getFormat('application/x-javascript'), 'js', '->getFormat() returns the format for the given mime type'); $request->setFormat('js', array('application/x-javascript', 'text/js')); $t->is($request->getFormat('text/js'), 'js', '->setFormat() can take an array of mime types'); $t->is($request->getFormat('foo/bar'), null, '->getFormat() returns null if the mime type does not exist'); // ->getMimeType() $t->diag('->getMimeType()'); $t->is($request->getMimeType('js'), 'application/x-javascript', '->getMimeType() returns the first mime type for the given format'); $t->is($request->getMimeType('foo'), null, '->getMimeType() returns null if the format does not exist'); // ->getUriPrefix() $t->diag('->getUriPrefix()'); $_SERVER['SERVER_PORT'] = '80'; $_SERVER['HTTP_HOST'] = 'symfony-project.org:80'; $t->is($request->getUriPrefix(), 'http://symfony-project.org', '->getUriPrefix() returns no port for standard http port'); $_SERVER['HTTP_HOST'] = 'symfony-project.org'; $t->is($request->getUriPrefix(), 'http://symfony-project.org', '->getUriPrefix() works fine with no port in HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'symfony-project.org:8088'; $t->is($request->getUriPrefix(), 'http://symfony-project.org:8088', '->getUriPrefix() works for nonstandard http ports'); $_SERVER['HTTPS'] = 'on'; $_SERVER['SERVER_PORT'] = '443'; $_SERVER['HTTP_HOST'] = 'symfony-project.org:443'; $t->is($request->getUriPrefix(), 'https://symfony-project.org', '->getUriPrefix() returns no port for standard https port'); $_SERVER['HTTP_HOST'] = 'symfony-project.org'; $t->is($request->getUriPrefix(), 'https://symfony-project.org', '->getUriPrefix() works fine with no port in HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'symfony-project.org:8043'; $t->is($request->getUriPrefix(), 'https://symfony-project.org:8043', '->getUriPrefix() works for nonstandard https ports'); // ->getRemoteAddress() $t->diag('->getRemoteAddress()'); $_SERVER['REMOTE_ADDR'] = '127.0.0.1';