Problem/Motivation
I noticed the following errors in our tests which use EntityToJsonApi
/app/docroot/core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php:24
stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated
/app/docroot/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php:85
stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated
Turns out the register basic HTTP kernel doesn't call \Drupal\Core\StackMiddleware\NegotiationMiddleware which is how Drupal registers content types. So all responses from the basic kernel have null as the content type.
That means because \Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber::renderResponseBody cannot set the content type properly:
$response->setContent($serializer->encode($jsonapi_doc_object->getNormalization(), $format));
$response->headers->set('Content-Type', $request->getMimeType($format));
Maybe it's a core bug and not here? But caused by this module's service.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
mglamanComment #4
mglamanComment #5
bbralaTook a while, but yes! :)
Comment #7
bbrala