Closed wizardnet972 closed 4 years ago
Found why. I should add transfer-encoding.
like this:
const req1 = httpMocks.createRequest({
url: '/',
method: 'POST',
body: {
name: 'test',
},
headers: {
'content-type': 'application/x-www-form-urlencoded',
'transfer-encoding': 'chunked'
},
Your are right, but why do we have to set transfer-encoding?
This is because of the type-is
dependancy which is used by the req.is()
function
From the docs:
null
will be returned if the request does not have a body.
To determine if the request has a body it checks for the headers: transfer-encoding
or content-length
.
Neither of these seem to be set by httpMocks.createRequest({...})
Stale issue message
The post request is not valid.