How Web Requests Work: HTTP Basics Explained

Published by The Cyber Staff on

Aerial view of a city lit up at night, suggesting connected networks

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.

Aerial view of a city lit up at night, suggesting connected networks
Billions of web requests cross the internet every second. Photo: Nastya Dulhiier / Unsplash

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 GET to 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

MethodPurpose
GETRetrieve a resource, such as a web page or image
POSTSubmit data, such as a login form or new record
PUT / PATCHReplace or partially update an existing resource
DELETERemove a resource
HEADRetrieve only the headers, without the body

What Happens When You Visit a Website

  1. DNS lookup: Your device translates the domain name (www.example.com) into the server’s IP address.
  2. Connection: Your device opens a network connection to that address.
  3. 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.
  4. Request: The browser sends the HTTP request with its method, path, headers and any body.
  5. Server processing: The server checks who you are, runs application code and may query a database.
  6. 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:

RangeMeaningCommon examples
2xxSuccess200 OK, 201 Created
3xxRedirection301 Moved Permanently, 304 Not Modified
4xxClient error401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
5xxServer error500 Internal Server Error, 503 Service Unavailable
Lines of colorful HTML code on a dark screen
Behind every page is a series of requests and responses. Photo: Florian Olivo / Unsplash

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, HttpOnly and SameSite attributes 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

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *