iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

HTTP Messages

An HTTP exchange is a request from the client and a response from the server. Each message has a start line, headers, and an optional body.

Request shape

GET /about HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: text/html
Accept-Language: en-US

(empty body for GET)

Response shape

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1543
Cache-Control: max-age=3600

<!DOCTYPE html>…

Important status codes

ClassCodeMeaning
2xx Success200OK
201Created
204No Content
3xx Redirection301Moved Permanently
302Found (temporary redirect)
304Not Modified (cache hit)
4xx Client errors400Bad Request
401Unauthorized
403Forbidden
404Not Found
409Conflict
422Unprocessable Entity
429Too Many Requests
5xx Server errors500Internal Server Error
502Bad Gateway
503Service Unavailable
504Gateway Timeout
Tip: Open your browser's dev tools and switch to the Network tab. Every request and response is right there, headers and all — the best way to learn HTTP is to watch real traffic.

Example

Example
<!DOCTYPE html>
<html>
<head>
    <title>HTTP Messages</title>
</head>
<body>

<h1>HTTP Messages</h1>
<p>This is a demo page for the "HTTP Messages" lesson.</p>

</body>
</html>
Try it Yourself »

Exercise

What HTTP status code means "OK, success"?

HTTP OK

Test yourself

Q1. HTTP request has…
Q2. A 200 status means…
Q3. A 404 means…

Discussion

Loading…