Closed juliardi closed 5 years ago
That sounds wrong. I would expect it to return null
or whatever you set it to using ServerRequest::withParsedBody()
. Do you have any code that shows the problem?
How do you create the server request? Could you give us 10-20 lines of example code?
I am using the example code from https://github.com/Nyholm/psr7-server/blob/master/README.md. I'll check my code again to make sure.
Nyholm/psr7-server always puts PHP’s $_POST
as the parsed body of a request, defaulting to an empty array. It doesn’t do any parsing itself, and will not try to parse non-form encoded requests. (Arguably it should default to null
.)
There are a number of middleware available that will parse other types of request content, e.g. Zend includes a JSON parser in their Expressive Helpers.
After checking the request, I found out that the request doesn't include Content-Type: application/x-www-form-urlencoded
or Content-Type: multipart/form-data
in its header. When the request included one of those headers, ServerRequest::getParsedBody
works fine.
I am trying to get the request's parsed body using
ServerRequest::getParsedBody
method, but it always returns an empty array. I've checked the code and do not find the code related to parsing request's body. Is this the intended behaviour?