Let's lift the hood and check out the engine that makes the World Wide Web run.
Browsers - what do they do?
- A web browser is a computer application that reads files.
- When entering a URL (ex. https://www.facebook.com) into the address bar in a browser, the browser requests information in the form of a file associated with that specific URL.
- Your browser renders code in the form of a website.
Request - Response
- HTTP stands for Hypertext Transfer Protocol.
- In a nutshell, an HTTP request is sent by the client (a browser), which is used to locate information in the form of a file.
- This file contains code, which tells your browser how, and what, to render.
- A web server responds to this request, by telling the browser where the file lives.
HTTP is a protocol that allows clients to communicate with web servers, and is a primary underlying infrastructure of the Internet. The two most common HTTP methods are:
When a URL is inputted, the browser sends a
GET request to a web server. When a form is submitted on a website, a
POST request is submitted, and the browser hands off the form data to be handled by the web server.
(There are several more HTTP Methods but GET and POST are used for 99.99%+ of Web traffic.)
- DNS stands for Domain Name Service
- This is a standardized way for a browser to know where your website lives.
- Your browser communicates with a nameserver, which tells your browser the IP address of where the files for your website are located.
- Information on your nameservers are known as DNS Records.
Remember, websites live at an IP Address. This is a string of numbers, (ex. 184.108.40.206) that locates a specific computer (or "host") on the Internet. A domain name is simply a translation that provides humans with an easy way to remember where a website lives.
Other DNS Info
Your nameservers may also contain other information about your domain, such as where your email server lives. For example, if I try to send an email to firstname.lastname@example.org, your email server is going to communicate with the nameserver for
facebook.com and say, "Where does this email server live?".
HTTP: File Transfer for the Web
HTTP: HyperText Transfer Protocol
- Invented in ~1991 by Tim Berners-Lee as part of the World Wide Web
- Uses TCP/IP: Internet Protocol
- see A Brief History of HTTP
Essentially, HTTP is a file transfer protocol
- every HTTP response contains a body which is often the raw, complete contents of a file
- these files can be images, sounds, data, or code
Examples of Web Code
Web code can be any language used to create web pages or applications. Common examples of these are
The above languages run inside the web browser (aka "the client side"). On the server side, there is a lot more variation. You may encounter...
HTTP 0.9 Goals (1991)
- very simple protocol, geared towards ease of use and implementation
- 100% ASCII characters in and out
- Human readability was a goal
- stateless meaning "one request, one response, and close"
HTTP 1.0 (1993-1996)
- developed ad hoc as the early WWW exploded
- many early decisions were odd, but we are now stuck with them
- same basic idea as HTTP 0.9, but with
- a version identifier
- request headers
- response status line
- response headers
- still stateless but some headers (notably
Cookie:) pass state back and forth
HTTP 1.0 protocol
|request a resource||
HTTP 1.0 details
port is a TCP/IP concept that lets a single host run several services
- the default port for HTTP is 80
- the default port for HTTPS is 443
- Request and (part of) Response are still ASCII
Content-Typeheader allows different file types
- reused MIME: (Multipurpose Internet Mail Extensions) spec for file type names
Content-Lengthheader so the client knows how big a file to expect
- ...and many more headers to help clients and servers work together
HTTP telnet example
telnet is the original program for connecting to other computers on the Internet.
Unfortunately, many modern OSs don't ship with a working version of
telnet, so you should watch your instructor's terminal, or skip ahead to the next slide.
$ telnet google.com 80
That opens a connection to one of Google's many web servers.
In HTTP, the client starts the conversation, so type this and hit Enter:
then the server replies with an HTTP response!
If you have a working
telnet, try this yourself. Also try
telnet towel.blinkenlights.nl .