The HTTP module

We will cover the HTTP server module. Technically, you could write your HTTP server using the net module, but you do not have to.

Some of these functions are very similar to the net module functions. This should make sense as HTTP, at its core, is a network server.

All of these functions and objects are also used with the HTTPS module. The only difference is that for the options of createServer and https.request, you can pass certificates.

All of the following examples assume that the module has been loaded:

var http = require('http');

createServer

This creates an HTTP server:

http.createServer([requestListener])

Return Value

This returns an http.Server object.

Description

Much like net.createServer, this is required to serve anything. The ...

Get Web Developer's Reference Guide 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.