function NegotiationMiddleware::handle
Same name in other branches
- 9 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
- 10 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
- 11.x core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
File
-
core/
lib/ Drupal/ Core/ StackMiddleware/ NegotiationMiddleware.php, line 42
Class
- NegotiationMiddleware
- Provides a middleware to determine the content type upon the accept header.
Namespace
Drupal\Core\StackMiddlewareCode
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
// Register available mime types.
foreach ($this->formats as $format => $mime_type) {
$request->setFormat($format, $mime_type);
}
// Determine the request format using the negotiator.
if ($requested_format = $this->getContentType($request)) {
$request->setRequestFormat($requested_format);
}
return $this->app
->handle($request, $type, $catch);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.