Tutorial 1: HTTP, URLs, DNS, and Request Lifecycles

Unit 1 · Web architecture and protocols

Objectives

One request, many systems

A URL identifies a resource and often includes a scheme, host, port, path, query, and fragment. The browser resolves the host through DNS, opens a connection, sends an HTTP request, and interprets the response. HTTPS adds encryption and server authentication through TLS.

GET /courses?level=400 HTTP/1.1
Host: example.test
Accept: application/json

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=60

HTTP is stateless at the protocol level: each request carries the information needed for the server to process it. Applications can add state with cookies, sessions, tokens, or a database. Use methods intentionally: GET retrieves, POST creates or triggers processing, PUT replaces, PATCH partially updates, and DELETE removes.

Status codes communicate outcome: 2xx success, 3xx redirection, 4xx client-side problem, and 5xx server-side failure. Headers carry metadata such as content type, caching, authentication, and security policy.

Exercises

  1. Label every component of https://example.test:8443/catalog?tag=web#security.
  2. Design the request and response for retrieving one course as JSON.
  3. Explain what a browser cache may do when Cache-Control: max-age=60 is present.

Self-check

  1. What does DNS provide?
  2. Why is HTTPS different from HTTP?
  3. What is the difference between a 404 and a 500?

Self-Check Quiz

1. Which HTTP method is normally safe for retrieval?

Answer(A) GET is intended to retrieve a representation without changing server state.

2. What does a 404 indicate?

AnswerThe server could not find a current representation for the requested resource.

3. Why use a Content-Type header?

AnswerIt tells the recipient how to interpret the message body, such as HTML, JSON, or an image.

Homework

  1. Trace a request to a public web page using browser developer tools.
  2. Draw the request lifecycle from URL entry through rendered response.
  3. Design three REST endpoints for a course catalog and assign methods and status codes.
Sample answer

A strong trace identifies DNS, TLS, the request method and path, request headers, response status, response headers, and dependent asset requests. A course API might use GET /courses with 200, GET /courses/466 with 200 or 404, and POST /courses with 201 or 400. The design should explain caching and content type.

👤