Slim icon indicating copy to clipboard operation
Slim copied to clipboard

NotFound not content switching

Open CrazyCodeUK opened this issue 9 years ago • 2 comments

Version: Slim 3.7.0

There is an error in Slim/Slim/Handlers/NotFound.php on line 42

$contentType = $this->determineContentType($request); looks like it should actually be $contentType = $request->getContentType($request); To return the not found page in the same format as the request.

When an invalid page is requested with the header application/json a return type of text/html is given.

With a quick look through some of the other page like NotAllowed.php, they seem to have the same issue.

CrazyCodeUK avatar Feb 17 '17 22:02 CrazyCodeUK

I'm not sure what this is about.

Can you give us some details on the problem you are having?

geggleto avatar Mar 06 '17 16:03 geggleto

The determineContentType() method (link) does get the content-type from the request, but Slim can only handle so many content types (note the recommendation in the docblock to use willdurand/negotiation if your needs are more complex).

@geggleto

When an invalid page is requested with the header application/json a return type of text/html is given.

It looks like the regex the determineContentType() method is using only matches content types with +json, so text/html is returned when application/json is provided. Improved regex would solve this issue.

geekish avatar Mar 07 '17 16:03 geekish