Creating an HTTP server
HTTP is a stateless data transfer protocol built upon a request/response model: clients make requests to servers, which then return a response. Facilitating this sort of rapid patter network communication is the sort of I/O Node is designed to excel at, it has unsurprisingly become identified as primarily a toolkit for creating servers—though it can certainly be used to do much, much more. Throughout this book we will be creating many implementations of HTTP servers, as well as other protocol servers, and will be discussing best practices in more depth, contextualized within specific business cases. It is expected that you have already had some experience doing the same. For both of these reasons we will quickly move through a general overview into some more specialized uses.
At its simplest, an HTTP server responds to connection attempts, and manages data as it arrives and as it is sent along. A Node server is typically created using the createServer
method of the...