Web & Internet
How HTTP Works (Request → Response)
The idea, in plain English
HTTP (HyperText Transfer Protocol) is the language browsers and servers use to talk to each other. Think of ordering food at a restaurant. You, the browser, tell the waiter what you want. That's a request. The kitchen, the server, makes it. The waiter brings back a response, either what you asked for, or an apology that it's not available. Every time you open a web page, your browser sends a request and waits for a response.
How it works
- 1The client (your browser or an app) builds a request. It picks a method, like GET, and a path, like /home.
- 2The request travels to a server. A server is a computer whose whole job is to listen for requests and answer them.
- 3The server looks at the request and decides what to do. It builds a response: a status that says whether it worked, plus a body with the actual content.
- 4The response travels back to the client. The client reads it and shows you the result — a page, an error, or whatever it received.
When you'd use it
This happens every time a web page loads, every time you click a button that fetches new data, and every time a mobile app pulls your feed. It happens anywhere two computers exchange information over the web.
Common beginner mistakes
- Some people think the server 'pushes' pages to you without being asked. Normally the client always asks first, and the server only ever replies.
- Don't forget that each request and response usually stands alone. The server doesn't automatically remember your last request, unless something like a cookie (a small piece of stored data) reminds it who you are.
Try it — edit and run
Click the code to edit · press ⌘/Ctrl+↵ to run
Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.
Request: GET /home
Response: 200 Welcome home!
Request: GET /missing
Response: 404 Not FoundNot sure this is the right topic? See the learning paths → or where this leads →