Beginner 12 min

How an HTTP request works

Follow a request from browser to server and understand the response status and content.

Describe the request

An HTTP request includes a method, a target, and headers. It can have a body. A browser might use GET to request a list of lessons and POST to submit a form. A request for data should identify the resource it wants, and a changing operation should explain what changed.

How it works

Follow one request from start to finish. A client sends a method and a path, such as GET /books/42. A server decides what to do with that request and replies with a status and optional content. The client uses the status to decide whether to show the book or a missing-item message.

Read the response

The response delivers a status code and headers, and may include a body. A 200 response indicates success. A 404 means the requested resource was not found. A 500 signals a server-side failure. A network failure can occur before any HTTP response is received.

Choose a useful UI state

While waiting, show a pending state. A successful request that returns an empty collection can show an empty view, while a missing resource needs its own message. For unexpected or transient failures give the user a clear retry option when repeating the operation is appropriate.

Check your understanding

Match each successful server response or failure to the interface message that fits.

See the example and explanation
Example 1
Given 200 with []
Answer No entries yet
Example 2
Given 404 for a lesson
Answer Lesson not found
Example 3
Given Network disconnected
Answer Check your connection and retry

A successful empty response means the collection exists without records. A 404 means the requested resource could not be located. A network failure means the browser did not receive a response.

Open practice problem
Next lessonBuild an accessible HTML structure