Lesson 3.1
How the web works
You will understand what happens between typing an address and seeing a page, and be able to read any HTTP request and response.
Why this matters on a client engagement
Almost every system you touch on a client engagement talks over the web: the CRM, the ticketing tool, the data warehouse, the LLM API. When an integration fails, the first question is always what was sent, to where, and what came back. If you can read a request and a response, you can debug most integration problems yourself instead of waiting days for someone else.
What happens when you open a page
- Browser: You type shop.example.com/orders
- DNS resolver: Looks up name, returns IP address
- Browser: Opens TLS connection to that IP
- Web server: Sends certificate to prove identity
- Browser: Sends GET /orders with headers
- Web server: Checks request, builds the page
- Web server: Returns 200 OK, headers and HTML
- Browser: Reads HTML, asks for images and CSS
- Web server: Returns each extra file
- Browser: Shows the finished page
The short version
The web is a conversation between two programs. The client asks for something and the server answers. Your browser is a client. A Python script that calls an API is also a client. The server is a program on another computer that waits for requests and sends back responses.
Think of it like an internal request form in a company. You fill in a form with what you want (the request), send it to the right department (the server), and get back a reply with a result code and some content (the response). HTTP, the Hypertext Transfer Protocol, is the agreed format for that form. Because everyone uses the same format, any client can talk to any server.
Step by step: from address to page
Take the address https://shop.example.com/orders. It has three parts: the scheme (https), the host name (shop.example.com) and the path (/orders). Here is what happens when you press Enter.
- DNS lookup. Computers find each other by IP address, a number such as 93.184.215.14. The Domain Name System (DNS) is the internet's phone book. Your computer asks a DNS resolver for the IP address of shop.example.com and gets one back.
- Connection. The browser opens a connection to that IP address. With https it also runs TLS (Transport Layer Security): the server shows a certificate that proves who it is, and both sides agree on encryption keys.
- Request. The browser sends an HTTP request: a method (GET), the path (/orders), and headers such as which browser it is and which formats it accepts.
- Response. The server sends back a status code (200 means OK), response headers (for example Content-Type: text/html) and a body, the actual content.
- More requests. The HTML page mentions images, stylesheets and scripts. The browser sends a separate request for each one, which is why one page can make dozens of requests.
Methods, status codes and headers
The method says what you want to do. GET reads data. POST creates something new or submits data. PUT replaces a record and PATCH changes part of one. DELETE removes it. A safe habit: GET should never change anything on the server.
The status code is a three digit number that tells you how it went. Learn the families, not every number. 2xx means success (200 OK, 201 Created). 3xx means look elsewhere (301 moved permanently). 4xx means the client made a mistake: 400 bad request, 401 not authenticated, 403 not allowed, 404 not found, 429 too many requests. 5xx means the server failed: 500 internal error, 503 unavailable. The family tells you where to look first: 4xx means check what you sent, 5xx means the other side has a problem.
Headers are name and value pairs that carry extra information. Request headers include Authorization (who you are), Content-Type (the format of the body you are sending) and Accept (the format you want back). Response headers include Content-Type, Cache-Control (how long the response can be reused) and Set-Cookie.
HTTPS and why it matters
Plain HTTP sends everything as readable text, so anyone on the network path could read passwords or customer data. HTTPS is HTTP sent inside a TLS encrypted connection. The certificate check also proves you are talking to the real server and not an impostor. For client work the rule is simple: anything with credentials or business data goes over HTTPS only. If a client system only offers plain HTTP, raise it as a risk.
Where this shows up on an engagement
Inside a client's company the path between client and server is often longer than on the public internet. Requests may pass through a VPN, a corporate proxy or a firewall before they reach the server. A call that works from your laptop at home can fail on the client's network with a timeout, a certificate error or a 407 status (proxy authentication required). When that happens, the code is usually fine; the network path is different. Ask the client's IT team early which outbound addresses are allowed, especially for cloud LLM APIs.
Two more ideas come up all the time. A cookie is a small piece of data the server asks the browser to store and send back on later requests; it is how a site remembers that you are logged in. A session is the server's record of that logged in state. When you automate a system that normally needs a browser login, you usually need an API key or token instead, because scripts do not log in the way people do.
Finally, keep the browser's developer tools in mind as a free debugging tool. The Network tab shows every request a web application makes, which often reveals the internal API behind a screen the client uses every day. That can be the fastest route to the data you need for a proof of concept, but always ask the system owner before you call it directly.
Going deeper: see it from the command line
curl is a command line client installed on macOS, Linux and recent Windows. It lets you send a request and see the raw response without a browser. The -I option asks for headers only. nslookup shows the DNS step on its own.
nslookup example.com
curl -I https://example.com
curl -i https://example.comWorked example
Worked example: reading a real response
Run curl -I https://example.com in a terminal. The response below is real output from that command, shortened. Read it line by line.
- HTTP/2 200: the protocol version and the status code. 200 means the request worked.
- content-type: the body is an HTML page using UTF-8 text encoding.
- server: the software or service that answered. Here it is a content delivery network sitting in front of the real site.
- allow: this address only accepts GET and HEAD requests. A POST here would be refused.
- cf-cache-status: HIT means a cached copy was served, so the request may never have reached the original server. When a client says 'I changed it but nobody sees the change', caching is a common reason.
HTTP/2 200
content-type: text/html; charset=utf-8
server: cloudflare
allow: GET, HEAD
cf-cache-status: HITStart practicing
Inspect a real request
20 minGoal: See every part of an HTTP exchange yourself in the browser.
- Open any website you use at work, then open the browser developer tools (F12 or right click then Inspect) and choose the Network tab.
- Reload the page and click the first request in the list.
- Write down the method, the status code, two request headers and two response headers.
- Count how many requests the page made in total (shown at the bottom of the Network tab).
- Find one request that returned something other than 200 and write down its status code family.
Done when: You can explain to a colleague what each value you wrote down means and why the page needed more than one request.
Trace a page from the terminal
15 minGoal: Connect DNS, HTTPS and the response using only the command line.
- Open a terminal and run nslookup example.com. Write down one IP address.
- Run curl -I https://example.com and note the status code and content-type.
- Run curl -I http://example.com (plain http) and compare the status code and headers.
- Ask a free LLM chat such as Claude to explain any header you do not recognise, then check its answer on the MDN HTTP headers page.
Done when: You have a short note listing the IP address, the two status codes and one sentence on the difference between the http and https results.
Common mistakes
- Treating every error the same. A 4xx means fix your request; a 5xx means the server failed. Check the family before you start changing code.
- Using GET to change data. Browsers, caches and link previews may repeat GET requests, so use POST, PUT, PATCH or DELETE for changes.
- Ignoring caching. If a change does not appear, check Cache-Control and cache headers before assuming the deploy failed.
- Sending credentials over plain HTTP. Always confirm the address starts with https before any key, password or customer data is sent.
Check yourself
- What does DNS do, and what would you see if it failed?
- Name the five parts of an HTTP exchange from request to response.
- An API returns 403. Is the problem more likely on your side or the server side, and what would you check first?
- What does HTTPS protect against, and what does the certificate prove?
- Why does one web page usually produce many requests?