How Web Requests Work: HTTP Basics Explained

Every time you open a website, check your email or use a mobile app, your device sends web requests and receives responses, often hundreds of them for a single page. Understanding what happens in that exchange is the foundation for understanding how web applications work and how they are secured.

What Is a Web Request?
A web request is a message sent from a client, such as a web browser or mobile app, to a server, asking it to return or act on a resource. The server replies with a response. This conversation follows HTTP (Hypertext Transfer Protocol), and today it is almost always protected by encryption as HTTPS.
Anatomy of a Request
Here is a simplified example of what your browser sends when you visit a page:
GET /blog/ HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html
Cookie: session=abc123
- Method: The action being requested, here
GETto retrieve a page. - Path and host: Together with the scheme (https://), these form the URL of the resource.
- Headers: Extra information such as the browser type, accepted content formats, and cookies that identify your session.
- Body: Data sent to the server, such as a submitted form. A simple GET request usually has no body.
Common HTTP Methods
| Method | Purpose |
|---|---|
GET | Retrieve a resource, such as a web page or image |
POST | Submit data, such as a login form or new record |
PUT / PATCH | Replace or partially update an existing resource |
DELETE | Remove a resource |
HEAD | Retrieve only the headers, without the body |
What Happens When You Visit a Website
- DNS lookup: Your device translates the domain name (www.example.com) into the server’s IP address.
- Connection: Your device opens a network connection to that address.
- TLS handshake: For HTTPS, the browser verifies the server’s TLS certificate and the two sides agree on encryption keys, so the rest of the conversation is private and tamper-resistant.
- Request: The browser sends the HTTP request with its method, path, headers and any body.
- Server processing: The server checks who you are, runs application code and may query a database.
- Response: The server returns a status code, headers and content. The browser then makes additional requests for images, scripts and stylesheets, and reuses the connection where it can.
Reading the Response: Status Codes
Every response starts with a three-digit status code. The first digit tells you the category:
| Range | Meaning | Common examples |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created |
| 3xx | Redirection | 301 Moved Permanently, 304 Not Modified |
| 4xx | Client error | 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests |
| 5xx | Server error | 500 Internal Server Error, 503 Service Unavailable |

Why This Matters for Security
- HTTPS everywhere: Without encryption, anyone on the same network could read or alter requests, including passwords and session cookies. Sites should use HTTPS for every page.
- Sessions and cookies: After you log in, a session cookie identifies you on every request. Protecting it with the
Secure,HttpOnlyandSameSiteattributes makes it much harder to steal or misuse. - Never trust the client: Every part of a request, including form fields, headers and hidden values, can be modified by the sender. Servers must validate input and check permissions on every request.
- Security headers: Response headers such as Strict-Transport-Security and Content-Security-Policy instruct browsers to enforce HTTPS and limit what content a page may load.
You can see this in action yourself: open your browser’s developer tools (usually F12), select the Network tab, and reload a page to watch each request and response. Command-line tools such as curl let you send and inspect requests directly.
The Bottom Line
Web requests are the basic unit of communication on the web: a client asks, a server answers, and status codes report how it went. Understanding that exchange makes it far easier to troubleshoot websites, evaluate security and build safer applications. If you’d like help reviewing the security of your website or web application, contact us.
0 Comments