What Is HTTP? The Web's Communication Protocol Explained
A foundational guide to HTTP: how requests and responses work, methods, status codes, headers, cookies, and how HTTPS encrypts the connection.
Short answer
HTTP (HyperText Transfer Protocol) is the language your browser and a web server use to talk to each other. Your browser sends a request — "give me this page" — and the server sends back a response — "here's the page," or "I couldn't find it," or "you're not allowed."
The idea in one minute
Imagine you walk up to a restaurant counter and place an order. You specify what you want (a cheeseburger), any extras (no onions), and how you'd like it served (to go). The kitchen reads your order, prepares the food, and hands it back with a status: "order ready" or "we're out of that." HTTP works exactly like this, except the customer is a browser and the kitchen is a web server. Each transaction is independent — the protocol is stateless.
How HTTP actually works
A typical HTTP request:
GET /learn/what-is-http HTTP/1.1
Host: nyxeara.vip
User-Agent: Mozilla/5.0
Accept: text/html
And the server's response:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 45120
Set-Cookie: session=abc123; HttpOnly; Secure
<!DOCTYPE html>
<html>...
The first line of the request is the request line: method, path, and protocol version. The lines that follow are headers. A blank line separates headers from the optional body. Every file in a page load — HTML, CSS, JavaScript, images — is fetched over its own request-response pair, often in parallel.
The request flow
Every HTTP interaction follows the same four steps: client opens a TCP connection, client sends a request message, server sends a response message, connection closes (or stays open for reuse in HTTP/1.1 keep-alive). The request always originates from the client. The server never initiates contact.
A minimal example
A Flask endpoint that responds to a GET request:
from flask import Flask, request
app = Flask(__name__)
@app.route("/hello")
def hello():
name = request.args.get("name", "World")
return f"Hello, {name}!"
A visit to /hello?name=Alice returns Hello, Alice!. The name parameter is reflected directly into the response without encoding — a reflected XSS vulnerability. Any input from HTTP request parameters must be treated as untrusted.
Why statelessness matters
HTTP has no built-in memory between requests. Each request is a fresh transaction. This statelessness is why cookies, session tokens, and authentication headers exist — they are workarounds bolted on top of a protocol that inherently does not remember who you are. Statelessness also means every request must be independently validated; you cannot assume that because a previous request was authenticated, the next one is too.
What attackers look for
Attackers scan for missing security headers, cookies without Secure or HttpOnly, mixed content (HTTPS page loading HTTP resources), and HTTP endpoints that accept sensitive data (login forms, API keys) without redirecting to HTTPS. Any response that lacks Content-Security-Policy or Strict-Transport-Security is a candidate for further probing.
Detection
Inspect every response header for missing security controls: Set-Cookie without Secure or HttpOnly, absent Strict-Transport-Security or Content-Security-Policy, mixed content warnings. Tools: curl -I, browser DevTools Network tab, OWASP ZAP.
Verification: real vulnerability or false positive?
Confirm that a missing Secure flag is actually exploitable — check whether the site listens on HTTP. A cookie missing Secure on an HTTPS-only site is a misconfiguration but not directly exploitable. For mixed content, verify the browser actually loads the resource (modern browsers block mixed scripts). Run curl -v http://site.com/login and check if a cookie is set before the HTTPS redirect — if it is, the cookie was transmitted in cleartext.
Real-world impact
A session cookie without Secure can be sniffed over public Wi-Fi with tcpdump — immediate account takeover with no application-level exploit. Absent HSTS enables SSL stripping: an attacker intercepts the first HTTP request and keeps the user on HTTP indefinitely. A single mixed-content script gives the attacker full DOM control over an otherwise secure page.
Prevention
Enforce HTTPS on every response; redirect HTTP with 301. Set Strict-Transport-Security with a long max-age and includeSubDomains. Set Secure and HttpOnly on every authentication cookie. Set Content-Security-Policy, X-Content-Type-Options: nosniff, and X-Frame-Options: DENY. Audit external resources to ensure they load over HTTPS.
Related vulnerabilities
- XSS — unencoded user input reflected in the HTTP response body
- CSRF — forged HTTP request triggers a state change using the victim's cookies
- SSRF — server makes an HTTP request to an attacker-chosen destination
- Request smuggling — front-end and back-end servers disagree on request boundaries
Testing methodology (do this safely)
Inspect traffic with browser DevTools and curl -v. Check every response header and every cookie attribute. Test mixed content by loading the page over HTTPS and looking for insecure resource warnings. Only test your own applications or authorized targets.
Further reading
- MDN: An overview of HTTP
- RFC 9110: HTTP Semantics
- RFC 9111: HTTP Caching
- MITRE: CWE-319 — Cleartext Transmission of Sensitive Information
Nyxeara perspective
Automated scanners often flag missing Secure flags or absent HSTS as individual findings. But these are symptoms of a deeper gap: developers learn frameworks, not protocols. Every Nyxeara finding about a missing security header traces back to a developer who learned their framework's template syntax before learning how HTTP actually works. Understanding the raw protocol — what a client sends and what a server returns — is the shortest path to writing secure web applications.