Skip to Main Content
Eloquent JavaScript
book

Eloquent JavaScript

by Marijn Haverbeke
January 2011
Intermediate to advanced content levelIntermediate to advanced
224 pages
5h 43m
English
No Starch Press
Content preview from Eloquent JavaScript

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Eloquent JavaScript, 3rd Edition

Eloquent JavaScript, 3rd Edition

Marijn Haverbeke
Learn JavaScript

Learn JavaScript

Shaun Wassell

Publisher Resources

ISBN: 9781593272821Errata