-
Notifications
You must be signed in to change notification settings - Fork 558
Description
When phusion passenger receives a request in "chunked" mode, it does not strip out the content length infos from the body he is transmitting to the app.
In chunked mode, the requester does not send the content-length, instead it sends content split into packets, each packets beginning with its length information. The last packet must be empty and have a length of zero.
As of version 6.0.27, Phusion does not strip this length informations. So when Phusion Passenger receives a POST request with json content in chunked mode, the body it transmits to my ruby app looks like:
45
{
"email": "[email protected]",
"event": "unsubscribe"
}
0
Where "45" and "0" are unexpected content-length informations that gets my app into trouble when trying to parse json. My app was a ruby rack application using roda routing toolkit.
A sample curl request to reproduce the bug:
curl -v \
--url http://localhost/ \
--header 'transfer-encoding: chunked' \
--header 'content-length:' \
--header 'content-type: application/json' \
--data '{
"email": "[email protected]",
"event": "unsubscribe"
}'In my case, I needed to make the request two or three times with curl to have a real chunked mode request. The first time curl makes the request, it sends a "normal" request, with a content-length header, and no transfer-encoding header