Listening to both GET and POST, node.js server

Here's a basic http sever that I've built using this tutorial. I'll only show one function here that creates the server:

function Server(resourceMap, rootFolder) {

    this.resourceMap = resourceMap;
    this.rootFolder = rootFolder;

    function connectionHandler(socket) {
        var data = "";
        console.log('server connected');
        console.log('CONNECTED: ' + socket.remoteAddress +':'+ socket.remotePort);
        socket.setEncoding('utf8');
            socket.on('data',function(newData) {
                           console.log("NEW DATA\n" +    newData); data += newData;
                            });
        socket.on('end',function(data) {
                           console.log("DATA\n" + data);                                   router.route(data,socket,handle,resourceMap,rootFolder);
                            });
    }

    this.server = net.createServer(connectionHandler);

    this.port = undefined;

    this.startServer = function(port) {
        this.port = port;
        this.server.listen(port, function() { 
            console.log('server bound');});
    }
}

So as you can see, I have two listeners - data and end. When data is emitted I add what was sent to a variable, and when end is emitted I send this variable to another function. This doesn't work with GET request - all the data is sent at once and end is not emitted.

I have to be able to handle both methods. Also, this is a homework assignment which is why I can't use the http module.

Any suggestions? Thanks!

P.s. as I am new to node.js and JavaScript any general comments will be welcomed

GET verb doesn´t contain a body, that´s the reason why 'data' event is never fired. All the code example is only valid for verbs that have a body.

Of course you are learning but first you have to understand what you want to do and then think about the implementation. My recommendation is you continue with your training about nodejs.