Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebProfilerBundle] force the Content-Type to html in the web profiler controllers #8050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function showAction($token)
if (!$this->twig->getLoader()->exists($template)) {
$handler = new ExceptionHandler();

return new Response($handler->getContent($exception));
return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
}

$code = $exception->getStatusCode();
Expand All @@ -64,7 +64,7 @@ public function showAction($token)
'logger' => null,
'currentContent' => '',
)
));
), 200, array('Content-Type' => 'text/html'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forget it return new Response($handler->getContent($exception)); and return new Response($handler->getStylesheet($exception)); (whatever the content-type here is)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

/**
Expand All @@ -87,7 +87,7 @@ public function cssAction($token)
return new Response($handler->getStylesheet($exception));
}

return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'));
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, 'text/css');
}

protected function getTemplate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function homeAction()
{
$this->profiler->disable();

return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)));
return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)), 302, array('Content-Type' => 'text/html'));
}

/**
Expand All @@ -82,7 +82,7 @@ public function panelAction(Request $request, $token)
$page = $request->query->get('page', 'home');

if (!$profile = $this->profiler->loadProfile($token)) {
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token)));
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token)), 200, array('Content-Type' => 'text/html'));
}

if (!$profile->hasCollector($panel)) {
Expand All @@ -98,7 +98,7 @@ public function panelAction(Request $request, $token)
'request' => $request,
'templates' => $this->getTemplateManager()->getTemplates($profile),
'is_ajax' => $request->isXmlHttpRequest(),
)));
)), 200, array('Content-Type' => 'text/html'));
}

/**
Expand Down Expand Up @@ -134,7 +134,7 @@ public function purgeAction()
$this->profiler->disable();
$this->profiler->purge();

return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'purge')));
return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'purge')), 302, array('Content-Type' => 'text/html'));
}

/**
Expand All @@ -151,14 +151,14 @@ public function importAction(Request $request)
$file = $request->files->get('file');

if (empty($file) || !$file->isValid()) {
return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'upload_error')));
return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'upload_error')), 302, array('Content-Type' => 'text/html'));
}

if (!$profile = $this->profiler->import(file_get_contents($file->getPathname()))) {
return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'already_exists')));
return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'already_exists')), 302, array('Content-Type' => 'text/html'));
}

return new RedirectResponse($this->generator->generate('_profiler', array('token' => $profile->getToken())));
return new RedirectResponse($this->generator->generate('_profiler', array('token' => $profile->getToken())), 302, array('Content-Type' => 'text/html'));
}

/**
Expand All @@ -174,7 +174,7 @@ public function infoAction($about)

return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
'about' => $about
)));
)), 200, array('Content-Type' => 'text/html'));
}

/**
Expand All @@ -195,13 +195,13 @@ public function toolbarAction(Request $request, $token)
}

if (null === $token) {
return new Response();
return new Response('', 200, array('Content-Type' => 'text/html'));
}

$this->profiler->disable();

if (!$profile = $this->profiler->loadProfile($token)) {
return new Response();
return new Response('', 200, array('Content-Type' => 'text/html'));
}

// the toolbar position (top, bottom, normal, or null -- use the configuration)
Expand All @@ -222,7 +222,7 @@ public function toolbarAction(Request $request, $token)
'templates' => $this->getTemplateManager()->getTemplates($profile),
'profiler_url' => $url,
'token' => $token,
)));
)), 200, array('Content-Type' => 'text/html'));
}

/**
Expand Down Expand Up @@ -262,7 +262,7 @@ public function searchBarAction(Request $request)
'start' => $start,
'end' => $end,
'limit' => $limit,
)));
)), 200, array('Content-Type' => 'text/html'));
}

/**
Expand Down Expand Up @@ -297,7 +297,7 @@ public function searchResultsAction(Request $request, $token)
'end' => $end,
'limit' => $limit,
'panel' => null,
)));
)), 200, array('Content-Type' => 'text/html'));
}

/**
Expand Down Expand Up @@ -330,7 +330,7 @@ public function searchAction(Request $request)
}

if (!empty($token)) {
return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token)));
return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token)), 302, array('Content-Type' => 'text/html'));
}

$tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end);
Expand All @@ -343,7 +343,7 @@ public function searchAction(Request $request)
'start' => $start,
'end' => $end,
'limit' => $limit,
)));
)), 302, array('Content-Type' => 'text/html'));
}

/**
Expand All @@ -359,7 +359,7 @@ public function phpinfoAction()
phpinfo();
$phpinfo = ob_get_clean();

return new Response($phpinfo);
return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function panelAction($token)
$this->profiler->disable();

if (null === $this->matcher || null === $this->routes) {
return new Response('The Router is not enabled.');
return new Response('The Router is not enabled.', 200, array('Content-Type' => 'text/html'));
}

$profile = $this->profiler->loadProfile($token);
Expand All @@ -68,6 +68,6 @@ public function panelAction($token)
'request' => $request,
'router' => $profile->getCollector('router'),
'traces' => $matcher->getTraces($request->getPathInfo()),
)));
)), 200, array('Content-Type' => 'text/html'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forget it here: return new Response('The Router is not enabled.'); probably text/plain should also set a service unavailable status code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}