Skills / Back-end development and APIs / How the web talks: clients, servers and HTTP
How the web talks: clients, servers and HTTP
When you open an app, your phone or browser (the client) sends a message to a computer somewhere else (the server). The server does some work, perhaps reads a database, and sends a reply. That conversation follows a set of rules called HTTP.
An HTTP request has:
- A method saying what you want to do:
GET(read),POST(create),PUTorPATCH(update),DELETE(remove) - A path saying what it is about, such as
/orders/42 - Headers with extra details, such as who you are signed in as
- Sometimes a body with data, for example the new order as JSON
An HTTP response has:
- A status code:
200OK,201created,400bad request (the client sent something wrong),401not signed in,403signed in but not allowed,404not found,500the server failed - Headers, and usually a body, very often in JSON, a simple text format for data:
{"id": 42, "status": "shipped"}
The first digit tells you who to look at when something breaks: 4xx means the request was wrong, 5xx means the server has a problem.
The back end is everything on the server side: receiving requests, checking them, applying the business rules, talking to the database and sending back the right response. The user never sees it, but every login, payment and search depends on it.
You can watch this conversation yourself: open your browser's developer tools, go to the Network tab and reload any page.
The tutor gives hints, not finished answers. Log in to use it.