We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
$request->isXml();
Should validate the content type to be XML as well as check the validity of the content to be valid XML
$request->sentXml();
Should only validate the content type
The text was updated successfully, but these errors were encountered:
Users usually forget the accept header but, if a user sends content-type XML, they expect XML in return unless they explicitly state otherwise.
Determine if a user wants XML by checking both the request Accept and Content Type headers...
Request::macro('wantsXml', function (bool $checkContentType = false) { $acceptableTypes = $this->getAcceptableContentTypes(); $accepts = array_pop($acceptableTypes) ?? ''; $acceptsXml = Str::contains($accepts, ['/xml', '+xml']); if ($acceptsXml) { return true; } if (! $checkContentType) { return false; } return $this->getContentType() == 'xml'; }); // ... $request->wantsXml(true);
Sorry, something went wrong.
No branches or pull requests
Should validate the content type to be XML as well as check the validity of the content to be valid XML
Should only validate the content type
The text was updated successfully, but these errors were encountered: