Issue
Content negotiation fails when Content-Type header contains extra data.
Steps to reproduce
Using Postman, try either of the following requests:
User/Account/Avatar/Create user avatar
User/My Account/Avatar/Create my avatar
They will fail for 2 reasons:
- We're missing the below configs from
config/autoload/content-negotiation.global.php:
'user.avatar.create' => [
'Content-Type' => [
'multipart/form-data',
],
],
'user.my-avatar.create' => [
'Content-Type' => [
'multipart/form-data',
],
],
- The value of the
Content-Type header is not the expected multipart/form-data, but it also includes boundary, for example multipart/form-data; boundary=--------------------------991804545238237537455135. So, when the content negotiation feature tries to compare the value from the request against the configured value, they will not match.
As a result, Dotkernel API returns a 415 Unsupported Media Type response.
Solution
See https://github.com/dotkernel/api/blob/5.0/src/App/src/Middleware/ContentNegotiationMiddleware.php#L68
Issue
Content negotiation fails when
Content-Typeheader contains extra data.Steps to reproduce
Using Postman, try either of the following requests:
User/Account/Avatar/Create user avatarUser/My Account/Avatar/Create my avatarThey will fail for 2 reasons:
config/autoload/content-negotiation.global.php:Content-Typeheader is not the expectedmultipart/form-data, but it also includesboundary, for examplemultipart/form-data; boundary=--------------------------991804545238237537455135. So, when the content negotiation feature tries to compare the value from the request against the configured value, they will not match.As a result, Dotkernel API returns a
415 Unsupported Media Typeresponse.Solution
See https://github.com/dotkernel/api/blob/5.0/src/App/src/Middleware/ContentNegotiationMiddleware.php#L68