HTTP for security beginners: read a raw request and response

15 min read

TL;DR: An HTTP request is plain text: a request line (method, path, version), headers, a blank line and an optional body; the response is a status line, headers, a blank line and a body. Read both in the browser's Network tab or with curl -v, then change one field at a time and watch the status code: every field you can change is input, and the app either checks it or trusts it.

This is for learners who know what a website is but have never looked at the traffic underneath one. Everything below was captured on 25 November 2026 against CyberGym, our deliberately vulnerable practice app, with a throwaway account we registered for the purpose: first in a Chromium browser, then with curl 8.7.1 and OpenSSL 3.5. Send requests like these only to sites you own or have written permission to test.

It is the http item of Stage 1 on our hacking roadmap, and probably the one the rest of web security leans on most: injection, broken access control and session bugs all live in the fields below.

What does a raw HTTP request look like?

It is a few lines of text. HTTP/1.1, which CyberGym speaks, is defined in RFC 9112: a request line of method, target and version, then one header per line, then an empty line, then the body if there is one. Lines end with a carriage return and a line feed (\r\n). Nothing more is needed, which you can prove by typing a request by hand into an encrypted connection with openssl s_client:

printf 'GET /rest/admin/application-version HTTP/1.1\r\nHost: cybergym.hackergpt.app\r\nConnection: close\r\n\r\n' \
  | openssl s_client -quiet -connect cybergym.hackergpt.app:443 -servername cybergym.hackergpt.app 2>/dev/null
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 25 Nov 2026 18:41:02 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 20
Connection: close
Access-Control-Allow-Origin: *
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Feature-Policy: payment 'self'
X-Recruiting: /#/jobs
ETag: W/"14-TlLzQnOkHacD65vmj0e4cyAizMg"
Vary: Accept-Encoding

{"version":"19.1.1"}

Three request lines and a blank one got a full answer. The only header HTTP/1.1 requires from a client is Host, which says which site on that server you want (RFC 9112, section 3.2). Everything else a browser sends is optional, and everything in the request, Host included, is whatever the sender chose to type.

A real CyberGym request and response split into request line, headers, blank line and body, with the status line labelled

The authenticated basket request from the worked example below, labelled part by part.

The response has the same shape: a status line (HTTP/1.1 200 OK), headers, a blank line, the body. Browsers today often speak HTTP/2 or HTTP/3, which put the same fields into binary frames instead of text lines; DevTools and curl show them to you in this readable form either way.

How do I see the requests my browser sends?

Open the browser's developer tools (F12, or Cmd+Option+I on a Mac), pick the Network tab and reload the page. Every request the page makes appears as a row; click one to see its request headers, its response headers and the response body (Chrome DevTools: inspect network activity). Three controls matter from day one:

  • Fetch/XHR filters the list down to the API calls the page's JavaScript makes, which is where the data and most of the bugs are.
  • Preserve log keeps requests across a page change, so a login that redirects does not wipe the request you wanted to read.
  • Copy as cURL (right-click a request, Copy) gives you that exact request as a curl command, ready to replay and edit in a terminal (Network features reference).

We loaded CyberGym's home page in a clean headless Chromium 152 and recorded its traffic. One page view made 42 requests: the HTML document, scripts, styles, fonts and images, and 17 XHR calls. The XHR calls are the interesting ones, because they are the app's API:

GET /rest/admin/application-version          200
GET /rest/admin/application-configuration    200
GET /api/Challenges/?name=Score%20Board      200
GET /rest/languages                          200
GET /api/Quantitys/                          200
GET /rest/products/search?q=                 200

A path like /rest/admin/... answering a visitor who never logged in is worth a note on its own: the name says admin, the status says nobody checked. If the word endpoint is new, what an API endpoint is explains it in one page. On a large app this list gets long, which is the job AppMap does for your own site: it crawls the app and lists every API endpoint with the authentication each one requires.

What do HTTP methods and status codes tell a tester?

The method says what the client asks for, and the status code says what the server decided. RFC 9110 defines the methods below except PATCH, which has its own RFC, and the status codes. GET and HEAD read, POST creates or submits, PUT and PATCH change, DELETE removes, and OPTIONS asks what is allowed. GET, HEAD and OPTIONS are defined as safe (they should change nothing), and that word is a promise the developer makes, not a rule the server enforces.

Status codes come in five classes: 1xx informational, 2xx success, 3xx redirection, 4xx "your request is the problem", 5xx "the server failed" (MDN: HTTP response status codes). These are the ones we got from CyberGym in a few minutes, without logging in unless noted:

Request Status What it tells you
GET /api/Products/1 200 OK public, as expected for a shop
GET /api/Products/99999 404 Not Found ids are checked against what exists
POST /api/Users (registration) 201 Created the response carried Location: /api/Users/28, our new account's id
OPTIONS /api/Products/1 204 No Content Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
DELETE /api/Products/1 401 Unauthorized this method needs a login
GET /ftp/package.json.bak 403 Forbidden the body said "Only .md and .pdf files are allowed!"
GET /rest/admin/application-version with If-None-Match 304 Not Modified the ETag matched, so no body was sent
GET /rest/doesnotexist 500 Internal Server Error the error page printed a stack trace with server paths

Two of these are lessons rather than facts. The 403 names the rule that stopped you, which is an invitation to test how that rule is checked, but it does not prove the file exists: GET /ftp/doesnotexist.bak got the same 403, because the extension is checked first, while GET /ftp/doesnotexist.md got a 404. The file is real only because the /ftp/ directory listing shows it. The 500 printed Error: Unexpected path: /rest/doesnotexist followed by lines such as at /home/admin/juice-shop/build/routes/angular.js:42:18: the install path, the framework (Express) and the fact that CyberGym is built on OWASP Juice Shop. A production app should log that and show the user a plain error page.

A third lesson came from our own mistake. While collecting status codes we sent an unauthenticated PUT to a product, expecting a 401 like the DELETE, and got 200: the change had been saved. We put the original value back at once. A method list in an OPTIONS response says what the framework routes, not what is protected, and the difference shows up only when you try each method and read the status. On a shared practice target, try write methods only on objects that belong to your own account.

Which headers matter for security?

The ones that carry identity, describe the body, or tell the browser how to behave. Request headers are input you control; response headers are the server's instructions to the browser and, often, a description of the stack.

Header Direction Why a tester reads it
Host request which site the server should serve; some apps build links and password-reset URLs from it
Authorization request carries a token; CyberGym's API reads Bearer <JWT> here
Cookie / Set-Cookie both sessions and preferences; the flags on Set-Cookie decide who can read them
Content-Type both how the body is parsed; send JSON without it and some APIs misread or reject it
X-Forwarded-For, True-Client-IP request proxies add them, and any client can type them
Server, X-Powered-By response the software, sometimes its version
Access-Control-Allow-Origin response which other sites' scripts may read the response (CORS)
X-Frame-Options, X-Content-Type-Options, Content-Security-Policy, Strict-Transport-Security response browser protections; security headers covers each

CyberGym's responses carried X-Content-Type-Options: nosniff and X-Frame-Options: SAMEORIGIN, no Content-Security-Policy or Strict-Transport-Security, and Access-Control-Allow-Origin: * on every response we read, including the authenticated basket below. With a token sent in a header rather than a cookie, * alone does not let another site read your basket, because that site's script would need your token first. It is still a choice worth writing down when you map an app.

The IP headers deserve a test of their own, because an app behind a proxy cannot see the client's address directly and is tempted to believe a header instead. MDN's X-Forwarded-For page warns that such headers are easy to spoof and should be trusted only when set by your own proxy. On CyberGym, logged in as our practice account, we called the endpoint that records the login address, once as it was and once with one header added:

curl -s https://cybergym.hackergpt.app/rest/saveLoginIp -H "Authorization: Bearer $TOKEN"
curl -s https://cybergym.hackergpt.app/rest/saveLoginIp -H "Authorization: Bearer $TOKEN" -H "True-Client-IP: 203.0.113.7"
"lastLoginIp":"127.0.0.1"
"lastLoginIp":"203.0.113.7"

Without the header the app stored 127.0.0.1: it sees its own proxy, not us. With it, the app stored the address we typed (203.0.113.7 is reserved for documentation, so it belongs to nobody). $TOKEN is your own practice account's token, obtained as in the next section. Whatever an app does with that value next, in a log, an admin page or a rate limit, it is now doing with text a stranger chose.

How do cookies and session tokens keep you logged in?

HTTP has no memory of you between requests, so after a login the server hands the client something to send back every time: a session cookie or a token. The browser stores it and attaches it to later requests; the server checks it and decides who you are. Whoever holds that value is you, as far as the app knows, which is why the OWASP Session Management Cheat Sheet spends most of its length on keeping it secret.

A cookie normally arrives in a Set-Cookie response header, and its attributes decide its exposure (MDN: Set-Cookie): HttpOnly hides it from JavaScript, Secure keeps it off unencrypted connections, SameSite limits when other sites can make the browser send it, and Expires or Max-Age sets its lifetime.

We logged in through CyberGym's login form in the browser and read what happened. The login was one POST /rest/user/login whose JSON response held the token, with no Set-Cookie header at all. The page's JavaScript then stored the token itself: in a token cookie and in localStorage. The cookie's attributes, read from the browser:

token   httpOnly=False  secure=False  sameSite=None  path=/  expires in 8 hours

httpOnly=False here is forced by the design: a cookie that JavaScript writes is a cookie JavaScript can read, so any script that runs in the page, including an injected one (see XSS examples), can read the session. The next request the page made was GET /rest/basket/12, our basket, with the token in an Authorization: Bearer header.

The token is a JSON Web Token: three base64url parts separated by dots, a header, a payload and a signature. The first two are encoded, not encrypted, so anyone holding the token can read them. Decoded, ours said (values shortened):

{"typ": "JWT", "alg": "RS256"}
{"status": "success", "data": {"id": 28, "email": "<our practice address>", "password": "<32 hex characters>", "role": "customer", "lastLoginIp": "0.0.0.0", "totpSecret": "", "isActive": true}, "iat": 1795632279}

The payload carries the account's password hash, 32 hex characters, the length of an MD5 digest. CyberGym does this on purpose, as Juice Shop does; a real app should put an id in the token and nothing a reader could use. It also explains something odd: after the IP test above, /rest/user/whoami still reported "lastLoginIp":"0.0.0.0". That endpoint answers from the token, which was issued before the change, not from the database. A token is a snapshot of who you were when you logged in, and an app that trusts it for anything that changes later (role, active status) trusts stale data. Broken authentication examples goes further into logins and sessions.

How do I change one field at a time and read what the app trusts?

Take a request that works, change exactly one thing, send it again and compare the status code and body with the original. One change per request means that when the answer changes, you know which field caused it. We did this to the basket request the browser had sent, from curl:

curl -s -o /dev/null -w "%{http_code}\n" https://cybergym.hackergpt.app/rest/basket/12 -H "Authorization: Bearer $TOKEN"
What we changed Status What it means
nothing (the original request) 200 our basket: {"id":12,"UserId":28,"Products":[]}
removed the Authorization header 401 the endpoint requires a token
sent the token as a token cookie instead 401 this endpoint reads only the header
changed the token's last character 401 the page title said UnauthorizedError: invalid signature: the signature is checked

So far the app checks everything we touched about who is asking. The field we left alone is the 12 in the path: the basket id. Whether the server compares that id with the user in the token is the next one-field change, and on CyberGym the answer is a deliberate no; the IDOR example works through exactly that request and its fix. In our curl tests, /rest/user/whoami behaved the other way round from the basket and read only the cookie, as the Linux command line and curl article found: two endpoints of one app looked for the session in two different places. That article also covers the curl flags used here.

Each field of a request the client controls, and whether CyberGym checked it or used it as sent in our tests

What we changed, field by field, and what CyberGym did with it on 25 November 2026.

What should I practise next?

Practise reading before attacking. Open the Network tab on CyberGym, do one thing in the app (search, add to basket, log in) and write down every request it caused: method, path, the header or cookie that carries your identity, the status. Then replay one with Copy as cURL and change a single field. When the vocabulary is familiar, the OWASP Web Security Testing Guide organises those same fields into a testing method,.

None of this tells you an app is safe. It tells you what the app does with the fields you tried, which is the evidence every web finding starts from.

Key takeaways

  • Read every request as request line, headers, blank line and body; the response as status line, headers, blank line and body.
  • Use the Network tab's Fetch/XHR filter to find the API calls, then Copy as cURL to replay them from a terminal.
  • Treat every field you can type, including Host, True-Client-IP and the id in a path, as input the server must check.
  • Read a session token: a JWT's payload is readable by anyone who holds it, and it is a snapshot from login time.
  • Change one field per request and compare status codes; a 200 where you expected a 401 is the finding.

FAQ

What is the difference between an HTTP request and a response?

A request is what the client sends: a method, a path, headers and sometimes a body. A response is what the server sends back: a status code, headers and usually a body. Every page view is many of these pairs; the browser's Network tab lists each one.

What do 401 and 403 mean?

401 Unauthorized means the server did not get valid credentials, so logging in or sending a token may change the answer. 403 Forbidden means the server understood the request, and who you are if that matters, and still refuses. A 403 is not proof the thing exists: on CyberGym a made-up .bak file got the same 403 as a real one.

Are cookies and sessions the same thing?

No. A session is the server's memory that you logged in; a cookie is one way for the browser to carry the session's identifier or token back on each request. Some apps carry the token in an Authorization header instead, and some, like CyberGym, use both on different endpoints.

Can a website trust the headers my browser sends?

Only as input. Any client can send any header with any value, as curl shows, so a server should treat User-Agent, Referer or True-Client-IP as claims, not facts. Headers set by the site's own proxy can be trusted only if the proxy removes the client's copies first.

Do I need Burp Suite to learn HTTP?

No. The browser's developer tools show every request and response, and curl replays and edits them. An intercepting proxy such as Burp Suite or ZAP becomes useful when you want to change requests in flight and keep a history, but the fields it shows are the same.

Sources

Practise all of this on CyberGym, or point HackerGPT at your own site to map its requests for you.

All articles on Learn hacking