Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
One of the core tasks of Node.js is to act as a web server. This is such a key part of the system that when Ryan Dahl started the project, he rewrote the HTTP stack for V8 to make it nonblocking. Although both the API and the internals for the original HTTP implementation have morphed a lot since it was created, the core activities are still the same. The Node implementation of HTTP is nonblocking and fast. Much of the code has moved from C into JavaScript.
HTTP uses a pattern that is common in Node.
Pseudoclass factories provide an easy way to create a new server.[7] The http.createServer()
method provides us with a new instance of the HTTP
Server class, which is the class we use to define the
actions taken when Node receives incoming HTTP requests. There are a few
other main pieces of the HTTP module and other Node modules in general.
These are the events the Server class
fires and the data structures that are passed to the callbacks. Knowing
about these three types of class allows you to use the HTTP module
well.