Chapter 12. HTTP requests
As mentioned in Chapter 9, communication on the World Wide Web happens over the HTTP protocol. This chapter describes how to use this protocol to make your client-side program talk to your web server.
The HTTP Protocol
A simple HTTP request might look like this:
GET /files/data.txt HTTP/1.1 Host: eloquentjavascript.net User-Agent: My Imaginary Browser
This asks for the file files/data.txt
from the server at eloquentjavascript.net
. In addition, it specifies that this request uses
version 1.1 of the HTTP protocolâversion 1.0 is also still in use and works slightly
differently. The Host
and User-Agent
lines are called
headers. These follow a pattern: They start with a word that identifies the information they contain, followed ...
Get Eloquent JavaScript 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.