How HTTP works
When you open a URL, the client resolves the domain, opens a connection and sends an HTTP request. The request identifies a method, target and protocol version, followed by optional headers and a body.
GET /products HTTP/1.1
Host: example.com
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 12
{"items":[]}
The server returns a status code, response headers and usually a body. HTTP/1.1 and HTTP/2 run over TCP. HTTP/3 uses QUIC over UDP while keeping the same request-response model.
Parts of an HTTP message
- Method: states the action, such as
GET,POST,PUTorDELETE. - Target: identifies the resource, such as
/productsor/api/orders/42. - Headers: carry metadata such as
Content-Type,AuthorizationandUser-Agent. See HTTP headers. - Body: carries content such as HTML, JSON, form data or an uploaded file.
HTTP is stateless, so each request can be understood independently. Sites use cookies, authorization tokens and server-side sessions when they need to recognize a client across requests.
HTTP vs HTTPS
HTTPS uses the same methods, headers and status codes as HTTP, but protects the connection with SSL/TLS.
| Feature | HTTP | HTTPS |
|---|---|---|
| URL scheme | http:// |
https:// |
| Protection | No encryption | TLS encryption and authentication |
| Default port | 80 | 443 |
Plain HTTP can expose request paths, headers and bodies to systems carrying the traffic. HTTPS protects them between the client and the TLS endpoint.
HTTP through a proxy
An HTTP proxy receives requests from your client and forwards them to the destination. For plain HTTP, it can read the request and response. For HTTPS, the client usually sends CONNECT example.com:443, then exchanges encrypted TLS traffic through the resulting tunnel.
A forward proxy changes the source IP seen by the destination. It doesn’t automatically correct your headers, cookies or request behavior. If the proxy requires credentials and doesn’t receive valid ones, it can return 407 Proxy Authentication Required before contacting the website.
FAQ
What is HTTP used for?
HTTP carries web pages, images, downloads, video segments and API requests. Browsers, mobile apps and automated tools all use it to communicate with web servers.
Is HTTP secure?
No. Plain HTTP doesn’t encrypt or authenticate the connection, so sensitive data shouldn’t be sent through it. HTTPS adds TLS protection.
Can an HTTP proxy handle HTTPS traffic?
Yes, often. The proxy can create a tunnel with the CONNECT method, allowing the client and destination to establish an encrypted TLS connection through it.