This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
Closed
Description
- I was not able to find an open or closed issue matching what I'm seeing.
- This is not a question. (Questions should be asked on slack (Signup for Slack here) or our forums.)
Currently, if the content-type header contains application/json
, the JsonStrategy
always runs json_decode()
even if there is no body to decode.
Currently, json errors are saved in a global state (json_get_last_error()
and json_get_last_error_msg()
). I think it would be better if zend-expressive plays nice and does not taint that global state unless necessary by skipping the unnecessary json_decode()
call.
Code to reproduce the issue
(send a request with content-type application/json
but no request-body while having the body-params middleware configured)
see \ZendTest\Expressive\Helper\BodyParams\JsonStrategyTest::testEmptyRequestBodyYieldsNullParsedBodyWithNoExceptionThrown()
Expected results
json_last_error()
returns JSON_ERROR_NONE
Actual results
json_last_error()
returns JSON_ERROR_SYNTAX
Metadata
Assignees
Labels
No labels