#Why this matters
Web applications, REST APIs and cloud consoles run over HTTP or HTTPS. Browsers hide the underlying protocol behind rendered pages, limiting casual use to clicks and standard forms.
When debugging APIs, inspecting web logs or solving entry-level veb-tahlil challenges, you need to craft raw HTTP directly. Servers often branch on the HTTP method (GET versus PUT or OPTIONS) or require custom headers. Understanding how TLS 1.3 protects HTTPS also helps you catch downgrade risks, invalid certificates and unsafe header trust.
#Anatomy of an HTTP request and response
HTTP is a stateless application-layer request-response protocol. Plain HTTP uses TCP port 80 and HTTPS uses TCP port 443 (HTTP/3 uses QUIC over UDP/443). An HTTP/1.1 message has a start line, headers, a blank line (CRLF) and an optional body:
POST /api/login HTTP/1.1
Host: lab.local
Content-Type: application/json
X-Lab-Client: student
Content-Length: 27
{"username":"alice","ok":1}The server answers with a status line, headers, a blank line and an optional body:
HTTP/1.1 200 OK
Content-Type: application/json
Set-Cookie: session=abc123; HttpOnly; Secure
Content-Length: 19
{"status":"active"}In HTTP/1.1, the Host header is mandatory so one IP can serve multiple domains (virtual hosting). Status codes group outcomes by first digit:
| Range | Class | Common examples |
|---|---|---|
2xx |
Success | 200 OK, 201 Created, 204 No Content |
3xx |
Redirection | 301 Moved Permanently, 302 Found (Location header) |
4xx |
Client error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 405 Method Not Allowed |
5xx |
Server error | 500 Internal Server Error, 502 Bad Gateway |
A 405 Method Not Allowed response often includes an Allow header listing accepted methods.
#HTTP methods and why they matter
HTML forms send only GET or POST, but HTTP defines several verbs with distinct roles:
| Method | Body | Intended meaning | Web analysis notes |
|---|---|---|---|
GET |
No | Retrieve a resource | Parameters sit in the URL query string |
HEAD |
No | Headers only | Checks status or Content-Length |
POST |
Yes | Submit data or action | Carries form or JSON payloads |
PUT |
Yes | Create or replace resource | Common in APIs and method gates |
DELETE |
Optional | Remove a resource | Usually restricted to privileged roles |
OPTIONS |
No | Query allowed methods | May return Allow: GET, PUT, OPTIONS |
Because headers (User-Agent, Referer, X-Forwarded-For, custom X-*) are client-supplied text, any header can be forged unless a trusted proxy overwrites it.
#How HTTPS adds TLS 1.3 protection
Plain HTTP exposes URLs, cookies and credentials in cleartext. HTTPS wraps HTTP inside TLS 1.3 (RFC 8446), which replaces deprecated SSLv3, TLS 1.0 and TLS 1.1 and completes key exchange in one round trip (1-RTT). TLS provides:
- Confidentiality: AEAD encryption hides paths, headers and payloads.
- Integrity: Authentication tags detect tampering in transit.
- Authentication: The server presents a CA-signed X.509 certificate and proves key ownership.
Because SNI (Server Name Indication) sits in the unencrypted ClientHello, observers still see the target hostname while paths, headers and bodies stay hidden.
#Inspecting HTTP and TLS from the terminal
In curl, -i prints response headers, -v shows full request/response details, -X sets the method and -H adds a header. With openssl, s_client inspects certificates and negotiated TLS parameters.
$ curl -i -X OPTIONS http://lab.local:8080/gate
HTTP/1.1 204 No Content
Allow: OPTIONS, PUT
$ curl -i -X PUT -H "X-Lab-Client: student" http://lab.local:8080/gate
HTTP/1.1 200 OK
Content-Type: text/plain
Access granted: lab_token_verified
$ openssl s_client -connect lab.local:443 -servername lab.local </dev/null 2>/dev/null | grep -E "Protocol|Cipher|subject="
subject=CN = lab.local
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol : TLSv1.3#Defending and common mistakes
- Allowing plaintext HTTP: Redirect port 80 to HTTPS and send
Strict-Transport-Security(HSTS). - Using
curl -kin automation: Disabling certificate checks invites active man-in-the-middle interception. - Trusting client headers for auth: Never base access control on
User-Agent,Refereror unvalidatedX-Forwarded-For. - Leaving legacy TLS active: Disable SSLv3, TLS 1.0 and TLS 1.1; require TLS 1.2+ AEAD or TLS 1.3.
#Summary
- HTTP/1.1 pairs a method, path, headers (including
Host) and body with2xx-5xxstatus responses. - Beyond
GETandPOST, verbs likePUT,DELETEandOPTIONSare vital for APIs andveb-tahliltasks. - HTTPS uses TLS 1.3 for confidentiality, integrity and X.509 authentication in 1-RTT.
curl(-i,-v,-X,-H) andopenssl s_clientinspect methods, headers and TLS state directly.