Request events - Does the requestListener in http.createServer(requestListener) need to be a function with two parameters (request, response)?

As far as I understand createServer is a function that accepts a single parameter: a function which will execute every time there is a request.

Does this function requestListener in http.createServer(requestListener) need to be a function with exactly two parameters (request, response) or be a function that includes a function call to a function with the arguments (request, response)?

Also does the code response.end() need to be called in order for a request to properly complete?

  1. You can pass any function you want.
    However, if you want to do anything useful, you will need to use both parameters.

  2. Yes; every response must be ended.