A browser acts as a client: it sends a request and receives a response from a server. HTTP defines the structure of this conversation. You only need a browser and its developer tools for this lesson.
Read a request
In HTTP/1.1, the first line identifies the method and path. GET retrieves a resource. Host identifies the destination, while Accept indicates a preferred response format. The example below is a textual request, not a terminal command.
GET /api/lessons HTTP/1.1
Host: example.test
Accept: application/jsonUnderstand the response
200 indicates success, 404 means the resource was not found, and 500 indicates a server error. Content-Type describes the response format, such as HTML or JSON.
HTTP/1.1 200 OK
Content-Type: application/json
{"lessons": ["HTTP", "Python"]}Try it in your browser
Open developer tools, select Network and reload this page. Find the main document request and inspect its method, status and Content-Type. Compare them with a CSS request.
Check your understanding
Which status means a resource was not found: 200, 404 or 500?
Answer: 404.