Using Web Protocols
Node.js was built with web servers in mind. Using Node.js, we can quickly create a web server with a few lines of code, allowing us to customize the behavior of our server.
HTTP stands for HyperText Transfer Protocol and is an application layer protocol that underpins the World Wide Web (WWW). HTTP is a stateless protocol that was originally designed to facilitate communication between web browsers and servers. The recipes in this chapter will have a large emphasis on how to handle and send HTTP requests. Although the recipes do not require a deep understanding of how HTTP operates, it would be worthwhile reading a high-level overview if you’re completely new to the concept. MDN Web Docs provides an overview of HTTP at https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview.
This chapter will showcase the low-level core application programming interfaces (APIs) that Node.js provides for interacting with web protocols. We’ll start by making...