diff --git a/module/Rest/src/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddleware.php b/module/Rest/src/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddleware.php index 6a76795e..3a2f0f4d 100644 --- a/module/Rest/src/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddleware.php +++ b/module/Rest/src/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddleware.php @@ -30,9 +30,10 @@ class CreateShortCodeContentNegotiationMiddleware implements MiddlewareInterface return $response; } - $acceptedType = $request->hasHeader('Accept') - ? $this->determineAcceptTypeFromHeader($request->getHeaderLine('Accept')) - : $this->determineAcceptTypeFromQuery($request->getQueryParams()); + $query = $request->getQueryParams(); + $acceptedType = isset($query['format']) + ? $this->determineAcceptTypeFromQuery($query) + : $this->determineAcceptTypeFromHeader($request->getHeaderLine('Accept')); // If JSON was requested, return the response from next handler as is if ($acceptedType === self::JSON) { diff --git a/module/Rest/test/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddlewareTest.php b/module/Rest/test/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddlewareTest.php index 8a867788..450b9e1c 100644 --- a/module/Rest/test/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddlewareTest.php +++ b/module/Rest/test/Middleware/ShortCode/CreateShortCodeContentNegotiationMiddlewareTest.php @@ -74,6 +74,7 @@ class CreateShortCodeContentNegotiationMiddlewareTest extends TestCase ['application/json', [], 'application/json'], ['application/xml', [], 'application/json'], ['text/plain', [], 'text/plain'], + ['application/json', ['format' => 'txt'], 'text/plain'], ]; }