drahak / Restful

Drahak\Restful - Nette REST API bundle
0 stars 0 forks source link

empty needle #96

Open ondrej-tuhacek opened 8 years ago

ondrej-tuhacek commented 8 years ago

I tried to use this library on Nette 2.3.8, PHP 7.0.2. I ran into a problem in the file::method.

ResponseFactory::getPreferredContentType

There is a call to:

Strings::contains($mimeType, $formatMime)

which is called with the empty string "" parameter in $formatMime in the last iteration.

that gives me this warning:

strpos(): Empty needle

This happens when accessing the REST route from Chrome browser. The $contentType parameter for the method getPreferredContentType is:

text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

When I access the route via Fiddler and I put the Accept header with either application/xml or application/json, it works fine. So this probably happen only if the Accept header is missing.

Hard to say whether this should be fixed in Nette Strings class or in ResponseFactory class.