Request and response, line by line
Stage 1 · Lesson 4 · 15 minutes · Requires Lessons 1–3 and Stage 0 Lesson 3
The one-line answer
Stage 0 showed you the shape of an HTTP exchange. This lesson makes you fluent in it — because from Stage 2 onward, reading and modifying requests is the work.
Why you should care
You met HTTP in Stage 0. That was the map. This is the terrain.
Every tool you touch from here — Burp Suite, curl, an API client, a WAF log, a SOC alert — presents you with raw HTTP. Fluency means glancing at a request and immediately knowing what is normal, what is attacker-controlled, and what is worth testing.
This lesson also covers what Stage 0 deliberately skipped: content types, authentication headers, caching, CORS, redirects, and the security headers a defender actually configures.
How it actually works
A complete request, dissected
POST /api/v1/orders HTTP/1.1
Host: shop.example.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64)
Accept: application/json
Content-Type: application/json
Content-Length: 58
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Cookie: session=a8f3d9e2b1; theme=dark
Origin: https://shop.example.com
Referer: https://shop.example.com/checkout
{"product_id":88,"quantity":2,"address_id":140}Line 1 — method, path, version.
Headers — metadata, one per line, Name: value.
Blank line — separates headers from body. Mandatory.
Body — the payload. Only present on methods that carry one.
Every single one of those values came from the client. All of them are editable. That is Stage 0 Lesson 8 restated at the byte level.
Content types
The Content-Type header tells the server how to parse the body. Three forms dominate:
Form-encoded — traditional HTML forms:
Content-Type: application/x-www-form-urlencoded
product_id=88&quantity=2&address_id=140JSON — modern APIs:
Content-Type: application/json
{"product_id":88,"quantity":2}Multipart — file uploads:
Content-Type: multipart/form-data; boundary=----WebKitBoundary7MA4
------WebKitBoundary7MA4
Content-Disposition: form-data; name="file"; filename="report.pdf"
Content-Type: application/pdf
%PDF-1.4...
------WebKitBoundary7MA4--Why this matters for testing: changing the content type sometimes changes which parser handles your input, and different parsers have different flaws. An endpoint that safely handles form data may behave differently when handed JSON. This is a real technique you will use in Stage 3 and 4.
Note also that filename and the inner Content-Type in a multipart upload are client-supplied strings. A server that trusts either is vulnerable — a file named shell.php declared as image/jpeg is entirely possible to send.
Authentication headers
Three patterns account for nearly everything:
Cookie: session=a8f3d9e2b1Session identifier, sent automatically by the browser. Covered fully in Lesson 5.
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...A token, usually a JWT. Not sent automatically — the application must attach it, which is why token-based auth is naturally more resistant to CSRF.
Authorization: Basic cHJpeWE6cGFzc3dvcmQxMjM=Base64 of username:password. That is encoding, not encryption — Stage 0 Lesson 6. Basic auth over plain HTTP transmits credentials in effectively readable form on every request.
Response structure
HTTP/1.1 201 Created
Date: Fri, 14 Feb 2026 09:12:00 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 87
Location: /api/v1/orders/5521
Set-Cookie: session=b9c1f4a7; HttpOnly; Secure; SameSite=Lax
Cache-Control: no-store
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains
{"order_id":5521,"status":"confirmed","total":2499}Redirects
HTTP/1.1 302 Found
Location: /dashboard| Code | Meaning | Method preserved? |
|---|---|---|
301 | Moved permanently | May change to GET |
302 | Found, temporary | Often changes to GET |
307 | Temporary, strict | Yes |
308 | Permanent, strict | Yes |
Security relevance: if Location is built from user input, that is the open redirect from Stage 0 Lesson 5. Also worth knowing — a redirect response can still carry a body, and a server that redirects unauthenticated users to a login page while still sending the protected content in the body has leaked it entirely. Browsers hide this; curl and Burp do not.
Security headers a defender sets
These appear in responses and are worth recognising on sight:
| Header | Purpose |
|---|---|
Strict-Transport-Security | Force HTTPS for a set period |
Content-Security-Policy | Restrict which scripts may run — major XSS defence |
X-Content-Type-Options: nosniff | Stop the browser guessing content types |
X-Frame-Options / CSP frame-ancestors | Prevent clickjacking |
Referrer-Policy | Limit what is leaked in the Referer header |
Cache-Control: no-store | Keep sensitive responses out of caches |
Their absence is a legitimate, if low-severity, finding — and checking for them is standard in every web assessment report.
CORS, briefly
Browsers enforce the same-origin policy: JavaScript on a.com cannot read responses from b.com by default. CORS is the mechanism for relaxing that deliberately.
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Credentials: trueThe dangerous misconfiguration is reflecting the request's Origin header back while also allowing credentials. That effectively lets any site read authenticated responses on behalf of a logged-in victim. You will test for this in Stage 4.
Note carefully: CORS controls what browsers permit JavaScript to read. It does nothing about curl, Burp, or a script. It is not an access control.
HTTP versions
HTTP/1.1 — text-based, one request at a time per connection. What you will read in captures and what Burp displays.
HTTP/2 — binary, multiplexed, header compression. Same semantics, different wire format. Tools display it as if it were 1.1.
HTTP/3 — runs over QUIC, which is UDP-based.
You work at the semantic level, so version rarely changes your approach. It matters occasionally — request smuggling attacks in particular exploit disagreements between servers about where one request ends and the next begins.
See it yourself
Send a raw request by hand:
curl -v -X POST https://httpbin.org/post \
-H "Content-Type: application/json" \
-H "X-Custom-Header: anything-i-want" \
-d '{"test":"value"}'httpbin.org echoes back exactly what it received — it exists for this purpose, and using it is entirely legitimate. Note that you set an arbitrary header with no difficulty whatsoever.
Change your identity:
curl -A "Googlebot/2.1" https://example.com
curl -H "X-Forwarded-For: 127.0.0.1" https://httpbin.org/headersSome applications behave differently for crawlers. Some trust X-Forwarded-For. Both are Stage 0 Lesson 8 in practice.
Inspect headers only:
curl -I https://github.comLook at which security headers are present. Compare against a smaller site. The difference is instructive.
Follow a redirect chain:
curl -L -v https://bit.ly/example 2>&1 | grep -i "location\|HTTP/"Look at a real API exchange. Open any application you use, devtools → Network → filter Fetch/XHR, perform an action. Read the full request and response. Ask three questions: what identifies me, what did I control, and did the response contain more than the page displayed?
Boundary: everything above targets
httpbin.org(built for testing), public homepages, or your own sessions. Sending crafted requests to applications you do not own is testing, and it needs permission. Stage 0 Lesson 9.
How attackers abuse this
Header injection. Unsanitised input reaching response headers can inject new headers or split the response. Modern servers mostly prevent this, but it still appears.
Host header attacks. Applications that build password reset links from the Host header can be made to send links pointing at an attacker's domain — a full account takeover from one header.
Content type confusion. Switching between JSON and form encoding to reach a different parser, or declaring a type the server does not expect to bypass validation.
Method override. Some frameworks honour X-HTTP-Method-Override: DELETE on a POST request, bypassing controls applied only to the real DELETE method.
Verb tampering. Access control applied to GET but not HEAD, or to documented methods but not PATCH.
Response smuggling and desync. Disagreements between a front-end proxy and back-end server about request boundaries, exploited to poison other users' responses. Advanced, but worth knowing the name.
Reading what the UI hid. As above — a redirect that still ships the protected body, or an API returning fields the front end never renders.
Common mistakes
"The browser will not let me send that." The browser is one client among many. curl sends anything. Restrictions enforced only in the browser are not restrictions.
"CORS protects my API." CORS restricts browser JavaScript. It is not authentication and it is not an access control. An API relying on CORS alone is unprotected against any non-browser client.
"Security headers make the application secure." They mitigate specific classes of attack. They do nothing about broken authorisation, injection, or logic flaws.
"HTTPS means I cannot see the request." You are one endpoint of that connection. Your own browser and your own proxy decrypt it. HTTPS protects against third parties in the middle, not against the user.
Check yourself
- An application returns
302 Foundredirecting to/login, but the response body contains the full admin dashboard HTML. Why is this a serious finding, and why would a normal user never notice? - Why does
Authorization: Bearerprovide inherent CSRF resistance that a session cookie does not? - A response includes
Access-Control-Allow-Originreflecting whateverOriginwas sent, plusAccess-Control-Allow-Credentials: true. What is the impact?
Answers
- The server performed authorisation on the redirect but generated and sent the protected content anyway. Any client that does not automatically follow redirects —
curl, Burp, a script — receives the full dashboard. Browsers follow the redirect and discard the body, so a normal user sees only the login page and the leak stays invisible.
- Browsers attach cookies automatically to any request to the matching domain, including requests triggered by a malicious third-party site. An
Authorizationheader must be added explicitly by the application's own JavaScript, which the same-origin policy prevents a foreign site from doing. The token therefore is not sent on cross-site requests by default.
- Any website can make an authenticated cross-origin request on behalf of a logged-in victim and read the full response, because the reflected origin makes every origin allowed while credentials are permitted. This is effectively a total bypass of the same-origin policy for that endpoint — commonly high severity.
Your lab
Challenge 07 — Read the headers
A response contains more than the page shows. Read the full exchange and find what the browser discarded.
→ Open Stage 1 labs
Summary in your language
தமிழ் சுருக்கம் (Tamil summary)
Request மற்றும் Response — வரி வரியாக
Stage 0-ல் HTTP-ன் வடிவத்தை பார்த்தோம். இப்போது அதை ஆழமாக.
ஒரு request-ன் அமைப்பு:
POST /api/v1/orders HTTP/1.1 ← method, path
Host: shop.example.com ← headers
Content-Type: application/json
Authorization: Bearer eyJhbG...
Cookie: session=a8f3d9e2b1
← வெற்று வரி (கட்டாயம்)
{"product_id":88,"quantity":2} ← bodyமுக்கியமான உண்மை: இதில் உள்ள ஒவ்வொரு மதிப்பும் client-ல் இருந்து வந்தது. எல்லாவற்றையும் மாற்ற முடியும்.
Content-Type — body-ஐ எப்படி படிக்க வேண்டும் என்பதை சொல்கிறது:
application/x-www-form-urlencoded— பழைய HTML formsapplication/json— நவீன API-கள்multipart/form-data— file upload
சோதனையில் ஏன் முக்கியம்? Content-Type-ஐ மாற்றினால், server-ல் வேறு parser இயங்கும். ஒவ்வொரு parser-க்கும் வெவ்வேறு பலவீனங்கள் உண்டு.
Authentication-ன் மூன்று வடிவங்கள்:
Cookie: session=...— browser தானாக அனுப்பும்Authorization: Bearer ...— application தான் சேர்க்க வேண்டும் (எனவே CSRF-க்கு எதிர்ப்பு உண்டு)Authorization: Basic ...— இது Base64 மட்டும்தான், encryption அல்ல
Redirect-ல் ஒரு முக்கியமான bug:
302 Found கொடுத்து login பக்கத்திற்கு அனுப்பும் server, சில நேரங்களில் பாதுகாக்கப்பட்ட உள்ளடக்கத்தையும் body-ல் அனுப்பிவிடும்.
Browser அதை மறைத்துவிடும். ஆனால் curl அல்லது Burp அதைக் காட்டும். இது உண்மையான, தீவிரமான finding.
CORS பற்றி தவறான புரிதல்:
CORS என்பது browser-ல் உள்ள JavaScript-ஐ மட்டும் கட்டுப்படுத்துகிறது. curl, Burp, script — இவற்றுக்கு CORS எந்த தடையும் இல்லை.
எனவே CORS ஒரு access control அல்ல. API-ஐ பாதுகாக்க authentication தேவை.
Security headers — defender அமைப்பவை:
Strict-Transport-Security— HTTPS-ஐ கட்டாயமாக்கும்Content-Security-Policy— XSS-க்கு எதிரான முக்கிய தடுப்புX-Frame-Options— clickjacking தடுப்பு
இவை இல்லாதது ஒரு (சிறிய) finding — ஒவ்வொரு report-லும் இது சரிபார்க்கப்படும்.
हिंदी सारांश (Hindi summary)
Request और Response — पंक्ति दर पंक्ति
Stage 0 में HTTP का आकार देखा था। अब उसे गहराई से।
एक request की संरचना:
POST /api/v1/orders HTTP/1.1 ← method, path
Host: shop.example.com ← headers
Content-Type: application/json
Authorization: Bearer eyJhbG...
Cookie: session=a8f3d9e2b1
← खाली पंक्ति (अनिवार्य)
{"product_id":88,"quantity":2} ← bodyसबसे ज़रूरी बात: इसमें मौजूद हर मान client से आया है। सब कुछ बदला जा सकता है।
Content-Type — body को कैसे पढ़ना है, यह बताता है:
application/x-www-form-urlencoded— पुराने HTML formsapplication/json— आधुनिक APIsmultipart/form-data— file upload
testing में क्यों ज़रूरी है? Content-Type बदलने पर server में अलग parser चलता है। हर parser की कमज़ोरियाँ अलग होती हैं।
Authentication के तीन रूप:
Cookie: session=...— browser अपने आप भेजता हैAuthorization: Bearer ...— application को ख़ुद जोड़ना पड़ता है (इसलिए CSRF से बचाव है)Authorization: Basic ...— यह सिर्फ़ Base64 है, encryption नहीं
Redirect में एक अहम bug:
302 Found देकर login पेज पर भेजने वाला server, कभी-कभी सुरक्षित सामग्री भी body में भेज देता है।
Browser उसे छिपा देता है। लेकिन curl या Burp उसे दिखा देते हैं। यह असली और गंभीर finding है।
CORS को लेकर ग़लतफ़हमी:
CORS सिर्फ़ browser के JavaScript को नियंत्रित करता है। curl, Burp या किसी script पर CORS का कोई असर नहीं।
इसलिए CORS access control नहीं है। API को बचाने के लिए authentication चाहिए।
Security headers — जो defender लगाता है:
Strict-Transport-Security— HTTPS अनिवार्य करता हैContent-Security-Policy— XSS के ख़िलाफ़ मुख्य बचावX-Frame-Options— clickjacking से बचाव
इनका न होना एक (छोटी) finding है — हर report में यह जाँचा जाता है।
Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.
What's next
One piece of the request carries your entire identity. It deserves a lesson of its own — including why it leaks so often.
→ Lesson 5: Cookies, sessions and why they leak