World Wide Web (HTTP and HTML)
Context: FIT1047_MOC Β· the Application-layer flagship: browser β server via HTTP, pages described in HTML Β· Berners-Lee 1989, built on hypertext + URLs
Quick Revision
- π― Objective: read/write a raw HTTP exchange β request line + headers βΆ status line + headers + body; one page = MANY request-response cycles (each
<img>is a new GET).- β‘ Key Constraint: the anatomy labels β request line / request header / response status / response header / response body β exams mark by part-name.
π Core
- Two technologies β HTTP = the browserβserver conversation protocol; HTML = the page description format.
- Two founding ideas β hypertext (documents linking documents) + URL (a standard way to name them).
- Requestβresponse cycle β browser sends request through the stack, server answers with the document; embedded resources trigger further GETs.
π Exam Execution Trace β lecture session, verbatim
client: GET /~john/test.html HTTP/1.1 β request line (method, path, version)
Host: www.stanford.edu β request header
server: HTTP/1.1 200 OK β response status
Date: Thu, 05 Mar 2015 08:30:48 GMT β response headers
Server: Apache/1.3.26 (Unix)
Content-Type: text/html
β blank line separates
<html><body><h1>John</h1> β response body (HTML)
<img src="images/john.jpg">β¦Then the <img> tag causes a second cycle: GET /~john/images/john.jpg β 200 OK, Content-Type: image/jpeg, binary body.
π HTTP Methods
| Method | Does |
|---|---|
GET | retrieve the URL |
HEAD | retrieve headers only |
POST | send body data to the URL (forum post, cart item) β also returns a document |
| others | PUT, DELETE, OPTIONS⦠less common |
β οΈ Common Mistakes
- π‘ One page β one request β every embedded image/script/stylesheet is its own request-response cycle.
- π‘ POST also retrieves β it sends data AND gets a response document back β βPOST only uploadsβ is wrong.
- π‘ HTTP is plain text β human-readable on the wire (until TLS wraps it) β which is why exams can show raw sessions.
π§ Active Recall
Label the five anatomical parts of an HTTP exchange and write a minimal valid request.
Answer
- Short answer: Request line + request headers β response status + response headers + response body; minimal:
GET /page.html HTTP/1.1+Host: example.com.- Why: Host header matters β one server IP hosts many sites;
Host:selects which β mandatory since HTTP/1.1.
Loading a page with 3 images: how many request-response cycles, and which method fits adding a forum comment?
Answer
- Short answer: Four cycles (page + 3 images); the comment is a
POST(data travels in the request body).- Why: Method semantics β GET is retrieval-only by convention; state-changing submissions belong in POST.