HTTP 400 (Bad Request) AND forwarding the request to the handler
- From:
- Damon Danieli
- Date:
- 2011-09-13 @ 21:12
Hi all,
I was using vows to run integration tests against mongrel2+nodejs.
In one of my tests that required an HTTP POST, I had not set the
content-type/content-length header fields and noticed that I was getting
an HTTP 400 (Bad Request), but I also noticed that my handler on nodejs
received the message from mongrel2 and had processed it.
Are others seeing this and, if confirmed, I will post a bug on the
mongrel2 github page.
Network trace:
The client (src port 59803) sends an HTTP POST to proxy (dst port 9100)
T 2011/09/11 23:49:46.633539 127.0.0.1:59803 -> 127.0.0.1:9100 [AP]
POST /mm/gamename/gametype/?playersInParty=2&totalPlayers=4 HTTP/1.1..Host:
127.0.0.1:9100..Connection: close..Transfer-Encoding: chunked....0....
The proxy (src port 9100) replies with a HTTP 400 (Bad Request)
T 2011/09/11 23:49:46.636834 127.0.0.1:9100 -> 127.0.0.1:59803 [AP]
HTTP/1.1 400 Bad Request..Content-Type: text/plain..Connection: close..Cont
ent-Length: 11..Server: Mongrel2/1.7.5....Bad Request
BUT the proxy goes on to send the request via ZeroMQ to the appropriate
handler (send_port 9103 with FD4)
T 2011/09/11 23:49:46.637301 127.0.0.1:9103 -> 127.0.0.1:59796 [AP]
..............B765827D-2F3B-422F-8389-31028E5E3215 4 /mm/gamename/gametype/
294:{"PATH":"/mm/gamename/gametype/","x-forwarded-for":"127.0.0.1","transfe
r-encoding":"chunked","connection":"close","host":"127.0.0.1:9100","METHOD"
:"POST","VERSION":"HTTP/1.1","URI":"/mm/gamename/gametype/?playersInParty=2
&totalPlayers=4","QUERY":"playersInParty=2&totalPlayers=4","PATTERN":"/"},0
:,
The handler replied to the request (FD4)
T 2011/09/11 23:49:46.680007 127.0.0.1:59797 -> 127.0.0.1:9102 [AP]
..........B765827D-2F3B-422F-8389-31028E5E3215 1:4, HTTP/1.1 200 OK..X-Powe
red-By: Express..Content-Type: application/json; charset=utf-8..Content-Len
gth: 86..Connection: close....{"uri":"zgp://127.0.0.1:9110/gamename/gametyp
e/1bbb6ff2-5995-49fb-a479-12d10895586e/"}
By this time, the proxy has closed the connection (see Bad Request above),
and tells the handler that they tried to send to a closed FD:
####
T 2011/09/11 23:49:46.683836 127.0.0.1:9103 -> 127.0.0.1:59796 [AP]
Y.B765827D-2F3B-422F-8389-31028E5E3215 4 @* 17:{"METHOD":"JSON"},21:{"type"
:"disconnect"},
In this case, the client received a 400 Bad Request AND the handler
received the request, processed it without error and replied.