What happens in NodeJS if I call response.end() as soon as I receive a request without supplying any data, calling response.write(), or calling response.writeHead()? I’m curious about the answer from two angles:
1) the server angle – does this essentially take something off of a backend stack or heap within nodeJS that frees up some resources? or does something entirely different happen?
2) the client perspective – If this is coming from an ajax request that doesn’t expect to receive any data in response, can any problems arise?
1) All resources associated with the request and response are relinquished (made available for garbage collection)
2) node sends out a response with default headers and an empty body. It’s purely up to the client how to deal with that. In most cases, the client will regard the default headers as incomplete, but in the absence of a response body, there’s no alternative.