5

Handling HTTP Requests

The foundation of server-side web development is the ability to receive HTTP requests from clients and generate responses. In this chapter, I introduce the Node.js API for creating HTTP servers and explain how it can be used to receive and respond to requests. Table 5.1 puts the Node.js HTTP API in context.

Table 5.1: Putting the Node.js API in context

Question

Answer

What is it?

The http and https modules contain the functions and classes required to create HTTP and HTTPS servers, receive requests, and generate responses.

Why is it useful?

Receiving and responding to HTTP requests is the core feature of server-side web application development.

How is it used?

Servers are created with the

Get Mastering Node.js Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.