Tuesday, August 20, 2013

Node.js incorrectly parses HTTP methods (chmod777self.com)

First, however, let's modify our server script just a bit so we can see what the Node.js server's view of the request method received is:
  http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World " + request.method);
    response.end();
  }).listen(8888);
Start it up:
bash-3.2$ node server.js
Now do:
bash-3.2$ telnet 127.0.0.1 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GEM / HTTP/1.1
Host: example.org

HTTP/1.1 200 OK
Content-Type: text/plain
Date: Mon, 19 Aug 2013 20:48:04 GMT
Connection: keep-alive
Transfer-Encoding: chunked

f
Hello World GET
0

Read more