Requesting a page from the web server

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Requesting a page from the web server

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Once the browser has the IP address from the DNS, where does it send the HTTP request?
A To the web server at that IP address
B Back to the DNS server
2. What does the HTTP request tell the web server?
A Which colours the page should use
B Which web page or file the browser wants
3. What does the web server send back when the requested page exists?
A The HTML for the requested page
B The user's IP address and a cookie only
4. A browser requests shop.com/offers.html, but no file called offers.html exists on the server. What happens?
A The server sends back the home page HTML instead
B The server sends back an error such as 404
5. Which step happens first?
A The browser gets the IP address, then sends the HTTP request
B The browser sends the HTTP request, then gets the IP address

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1GET /index.html HTTP/1.1 AThe browser asks the web server for the page called index.html
2HTTP/1.1 200 OK BHTTP/1.1 404 Not Found
3After DNS gives the IP address, the browser sends its HTTP request to that address CThe server found the page and is sending its HTML back to the browser
4If the requested page does not exist, the server sends back an error instead of HTML DThe roles are the wrong way round: the browser sends the HTTP request and the web server sends back the HTML.
5The server sends the request to the browser, and the browser replies with the HTML E404 means an error because the page does not exist. A successful request returns 200 OK with the HTML.
6GET /contact.html -> 404 OK: page found, HTML sent FGET /shop.html -> 93.184.216.34

Definitions

HTTP request

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___ /index.html HTTP/1.1
2.
GET /index.html ____/1.1
3.
HTTP/1.1 ___ Not Found
4.
HTTP/1.1 200 OK Content-Type: text/____
5.
// Request goes to the server's __ address GET /shop.html HTTP/1.1

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A ip ← LOOKUP("www.shop.com")
B request ← "GET /index.html"
C SEND request TO html
D html ← RECEIVE()
Question 2
A ip ← "93.184.216.34"
B request ← "SEND /about.html"
C SEND request TO ip
Question 3
A HTTP/1.1 404 OK
B Content-Type: text/html
C <html><body>Hi</body></html>
Question 4
A GET /missing.html HTTP/1.1
B HTTP/1.1 200 Not Found
C <h1>Page not found</h1>
Question 5
A IF page EXISTS ON browser THEN
B SEND html TO browser
C ELSE SEND "404" TO browser
D ENDIF

Answer Key

Requesting a page from the web server
Section A: Quick Questions
Q1
A — To the web server at that IP address
Q2
B — Which web page or file the browser wants
Q3
A — The HTML for the requested page
Q4
B — The server sends back an error such as 404
Q5
A — The browser gets the IP address, then sends the HTTP request
Section B: Match the Pairs
Q1
GET /index.html HTTP/1.1 → The browser asks the web server for the page called index.html
Q2
HTTP/1.1 200 OK → The server found the page and is sending its HTML back to the browser
Q3
After DNS gives the IP address, the browser sends its HTTP request to that address → GET /shop.html -> 93.184.216.34
Q4
If the requested page does not exist, the server sends back an error instead of HTML → HTTP/1.1 404 Not Found
Q5
The server sends the request to the browser, and the browser replies with the HTML → The roles are the wrong way round: the browser sends the HTTP request and the web server sends back the HTML.
Q6
GET /contact.html -> 404 OK: page found, HTML sent → 404 means an error because the page does not exist. A successful request returns 200 OK with the HTML.
Section C: Definitions
Q1
HTTP request — A message the browser sends to the web server's IP address asking for a page; the server replies with the page's HTML, or an error such as 404 if it does not exist.
Section D: Fill in the Blanks
Q1
GET /index.html HTTP/1.1
Q2
GET /index.html HTTP/1.1
Q3
HTTP/1.1 404 Not Found
Q4
HTTP/1.1 200 OK Content-Type: text/html
Q5
// Request goes to the server's IP address GET /shop.html HTTP/1.1
Section E: Spot the Error
Q1
C — The browser sends the HTTP request to the web server's IP address, not to the html. The line should be SEND request TO ip.
Q2
B — An HTTP request for a page uses the GET method. SEND is not an HTTP method. It should be request ← "GET /about.html".
Q3
A — When the server finds the page and sends the HTML back, the status is 200 OK. 404 means the page was not found. It should be HTTP/1.1 200 OK.
Q4
B — If the requested page does not exist, the server replies with the error code 404, not 200. It should be HTTP/1.1 404 Not Found.
Q5
A — The web server checks whether the requested page exists on the server, not on the browser. It should be IF page EXISTS ON server THEN.