Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

HTB Academy - Web Requests

HTB Academy - Web Requests: Keep a crisp, practical explainer of HTTP requests, responses, headers, and methods/status codes—with raw examples and copy‑paste cribs. This is the version I actually reference during testing. • HTB Academy • headers, htb-academy

2022-09-293 tags
Tags

🎯 Objective

Keep a crisp, practical explainer of HTTP requests, responses, headers, and methods/status codes—with raw examples and copy‑paste cribs. This is the version I actually reference during testing.


🌐 Big Picture

HTTP exchanges are a client request (browser/cURL) and a server response (web server/app). The request carries the target resource (URL/path/params), headers, and optionally a body. The server processes it and replies with a status code, headers, and often a response body.

HTTP/1.x is text‑based (newline‑delimited). HTTP/2 is binary/framed (HPACK, streams), but concepts—methods, status, headers—carry over.


📤 HTTP Request (anatomy)

Example request (GET a login page):

Request line has three space‑separated fields:

FieldExampleDescription
MethodGETVerb indicating action
Path/users/login.htmlResource path; may include a query string like ?username=user
VersionHTTP/1.1Protocol version

Then headers (name: value), then an empty line, then (for methods like POST/PUT/PATCH) an optional body.


📥 HTTP Response (anatomy)

Example raw response:

Status line: HTTP/1.1 200 OK → protocol + status code + reason.
Followed by headers and an optional body (HTML, JSON, images, PDFs, etc.).


🏷️ HTTP Headers (types)

General headers

Describe the message rather than its content (used on requests and responses).

HeaderExampleWhat it does
DateDate: Wed, 16 Feb 2022 10:38:44 GMTWhen the message originated (prefer UTC).
ConnectionConnection: closeclose or keep-alive to control TCP reuse.

Entity headers

Describe the content entity (commonly in responses, or POST/PUT bodies).

HeaderExampleWhat it does
Content-TypeContent-Type: text/html; charset=UTF-8MIME type + charset.
Content-LengthContent-Length: 385Byte length of body.
Content-EncodingContent-Encoding: gzipTransform like gzip/deflate/br.
boundaryboundary="b4e4fbd93540"Multipart delimiter for mixed parts.
Media-Typeapplication/pdf(Alias used in some docs; MIME governs behavior.)

Request headers

Used by the client; not about the message body itself.

HeaderExampleWhat it does
HostHost: www.inlanefreight.comVirtual host selection on the server.
User-AgentUser-Agent: curl/7.77.0Client identifier.
RefererReferer: https://google.com/Where the request came from (spoofable).
AcceptAccept: */*Media types the client accepts.
CookieCookie: PHPSESSID=b4e4fbd93540Client cookies (name=value; multiple via ;).
AuthorizationAuthorization: Basic cGFzc3dvcmQ=Client auth (Basic/Bearer/etc.).

Response headers

Used by the server; not about the body content.

HeaderExampleWhat it does
ServerServer: Apache/2.4.57Server software/version hint.
Set-CookieSet-Cookie: PHPSESSID=b4e4...; HttpOnly; SecureInstructs client to store cookies.
WWW-AuthenticateWWW-Authenticate: Basic realm="local"Signals required auth scheme.

Security headers

Policies to harden browser behavior.

HeaderExampleWhat it does
Content-Security-PolicyContent-Security-Policy: script-src 'self'Restricts script sources; mitigates XSS.
Strict-Transport-SecurityStrict-Transport-Security: max-age=31536000Force HTTPS (HSTS).
Referrer-PolicyReferrer-Policy: originControls Referer exposure.

Note: Apps can emit custom headers as needed.


📨 Methods (verbs)

Common ones you’ll see/testing basics:

MethodWhat it does
GETRetrieve a resource. Query via URL params.
POSTSend data in body (forms, uploads, JSON).
HEADLike GET but only headers (no body).
PUTReplace a resource (full update, often idempotent).
PATCHPartial update of a resource.
DELETERemove a resource.
OPTIONSDiscover server capabilities (allowed methods).

Many modern apps use mostly GET/POST; RESTful APIs often use PUT/DELETE/PATCH for updates.


🔢 Status codes (families)

  • 1xx: Informational (rare in browsing).
  • 2xx: Success (e.g., 200 OK).
  • 3xx: Redirects (e.g., 302 Found).
  • 4xx: Client errors (e.g., 400 Bad Request, 403 Forbidden, 404 Not Found).
  • 5xx: Server errors (500 Internal Server Error).

Quick examples:

  • 200 OK – Success; body contains the resource.
  • 302 Found – Temporary redirect (often after login).
  • 400 Bad Request – Malformed request (missing newline, bad JSON).
  • 403 Forbidden – Authenticated but not authorized (or input flagged).
  • 404 Not Found – Resource doesn’t exist.
  • 500 Internal Server Error – App/server blew up handling it.

📎 Copy‑paste crib

See exactly what cURL sends (HTTP/1.1):

bash
curl -v http://example.com/ -H 'Accept: text/html'

Send JSON (with correct content type):

bash
curl -sS -X POST 'https://api.example.com/items'   -H 'Content-Type: application/json'   -d '{"name":"demo","enabled":true}'

HEAD only (check size/headers without body):

bash
curl -I https://example.com/big.iso

Trace raw over TLS (handy when debugging headers):

bash
openssl s_client -connect example.com:443 -servername example.com
# then paste an HTTP/1.1 request:
# GET / HTTP/1.1
# Host: example.com
# Connection: close
#

OPTIONS to see allowed methods:

bash
curl -i -X OPTIONS https://api.example.com/resource

🧪 Troubleshooting

  • 415/400 → Content‑Type mismatch or malformed JSON.
  • CORS in browsers → Use server‑side or cURL (CORS is a browser policy).
  • Auth woes (401/403) → Recheck Authorization/cookies; capture via DevTools and replay.
  • Chunked vs length → Servers may use Transfer-Encoding: chunked instead of Content-Length.
  • HTTP/2 gotchas → Intermediaries may coalesce headers; use --http1.1 if behavior differs.

✅ TL;DR

  • Request = method + path + version + headers + body (optional).
  • Response = version + status + headers + body (optional).
  • Know the header categories, the core verbs, and the status families.
  • When stuck, capture in DevTools and replay with cURL—then iterate.
Navigate

In this post

  1. 01🎯 Objective
  2. 02🌐 Big Picture
  3. 03📤 HTTP Request (anatomy)
  4. 04📥 HTTP Response (anatomy)
  5. 05🏷️ HTTP Headers (types)
  6. 06General headers
  7. 07Entity headers
  8. 08Request headers
  9. 09Response headers
  10. 10Security headers
  11. 11📨 Methods (verbs)
  12. 12🔢 Status codes (families)
  13. 13📎 Copy‑paste crib
  14. 14🧪 Troubleshooting
  15. 15✅ TL;DR
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.