Skip to main content

Command Palette

Search for a command to run...

Understanding HTTP Requests

Published
โ€ข3 min readโ€ขView as Markdown
S

This blog serves as a beginner-friendly guide to understanding the world of cybersecurity. From defining what cybersecurity is to exploring its two major domainsโ€”offensive and defensive securityโ€”it breaks down various career paths such as Security Analyst, Engineer, Penetration Tester, and more. Whether you're just curious or planning a career, this blog gives you the insight and direction to get started in the cybersecurity field.

๐ŸŒ Understanding HTTP Requests: Request Line, Methods, Headers & Body

When you visit a website, log in, or submit a form, your browser sends something called an HTTP request to the server. If you're learning about web development or cybersecurity, understanding this is super important!

Letโ€™s break it down into four main parts:


๐Ÿ“Œ 1. Request Line (Start Line)

The request line is the first part of the HTTP request. It tells the server:

  • What to do (method)

  • Where to do it (path)

  • How to communicate (HTTP version)

โœจ Example:

pgsqlCopyEditGET /login HTTP/1.1

๐Ÿ”น It includes:

  • Method โ€“ Example: GET, POST, etc.

  • Path โ€“ The URL path. Example: /login

  • Version โ€“ Like HTTP/1.1, HTTP/2, etc.


๐Ÿ”ง 2. HTTP Methods

Each method tells the server what kind of action the user wants to perform.

MethodPurposeSecurity Tip ๐Ÿ”’
GETRetrieve dataDonโ€™t send sensitive info like passwords
POSTSend data (like login info)Always validate input
PUTUpdate or replace dataCheck user permission
DELETEDelete dataOnly allow authorised users
PATCHUpdate part of a resourceValidate data carefully
HEADLike GET, but no bodyUsed to check metadata
OPTIONSLists allowed methodsCan be disabled if not needed
TRACEDebugging toolDisable it for security
CONNECTCreates secure tunnel (HTTPS)Used in secure browsing

๐Ÿ“ฅ 3. Request Headers

Request headers give extra details about the request. These help the server understand how to handle it.

๐Ÿ”น Common Headers:

HeaderExampleWhat It Does
HostHost: tryhackme.comTells which website the request is for
User-AgentUser-Agent: Mozilla/5.0Info about the browser or client
RefererReferer: https://www.google.com/Shows where the user came from
CookieCookie: user_type=student; room_status=in_progressSends stored data like login/session info
Content-TypeContent-Type: application/jsonDescribes the format of data in the body

๐Ÿ“Œ Fill in the blanks?
_______ _______ = Request Headers โœ…


๐Ÿงพ 4. Request Body

The request body carries data when the client is sending something to the server โ€” usually with POST or PUT methods.

๐Ÿง  Formats used in the body:


๐Ÿ”ธ a) URL Encoded (application/x-www-form-urlencoded)

  • Key-value pairs like: key1=value1&key2=value2

  • Common in login forms

httpCopyEditPOST /profile HTTP/1.1
Content-Type: application/x-www-form-urlencoded

name=Aleksandra&age=27&country=US

๐Ÿ”ธ b) Form Data (multipart/form-data)

  • Used for uploading files or images

  • Data is split using a boundary

httpCopyEditPOST /upload HTTP/1.1
Content-Type: multipart/form-data; boundary=----boundary123

----boundary123
Content-Disposition: form-data; name="username"

aleksandra
----boundary123
Content-Disposition: form-data; name="profile_pic"; filename="aleksandra.jpg"
Content-Type: image/jpeg

[Binary image data here]
----boundary123--

๐Ÿ”ธ c) JSON (application/json)

  • Common in APIs

  • Uses key-value pairs with curly braces

hCopyEditPOST /api/user HTTP/1.1
Content-Type: application/json

{
  "name": "Aleksandra",
  "age": 27,
  "country": "US"
}

๐Ÿ”ธ d) XML (application/xml)

  • Uses opening and closing tags

  • Example of nested data

httpCopyEditPOST /api/user HTTP/1.1
Content-Type: application/xml

<user>
  <name>Aleksandra</name>
  <age>27</age>
  <country>US</country>
</user>

โœ… Quick Recap

  • Default content type for forms? โ†’ application/x-www-form-urlencoded

  • Where is Host, User-Agent, Content-Type found? โ†’ Request Headers


Got questions or want to learn more about HTTP responses next? Drop a comment below! ๐Ÿ’ฌโœจ

More from this blog

A

A's BLACKHOLE

76 posts

This blog serves as a beginner-friendly guide to understanding the world of cybersecurity.