Java.Servlets.Which HTTP method is not immutable?

🧠 First: What is an immutable HTTP method?

In HTTP, a method is considered immutable (or safe) if:

  • It does NOT change anything on the server.
  • It’s supposed to be read-only (just retrieves data).

Examples of immutable (safe) methods:

MethodSafe?What it does
GET✅ YesRetrieves a resource (no changes)
HEAD✅ YesSame as GET but no response body
OPTIONS✅ YesAsks what methods are supported
TRACE✅ YesEchoes the request for diagnostics

🎯 Now, answering your question:

Which HTTP method is not immutable?

👉 POST is not immutable!

POST is intended to:

  • Create new resources
  • Modify server-side data
  • Submit forms
  • Trigger side-effects (e.g., send email, update a database)

Thus, POST changes server state
→ so it’s not immutable (not safe).


🚀 Other HTTP methods that are also not immutable:

MethodMutabilityPurpose
POSTMutableCreate or process a resource
PUTMutableReplace a resource
DELETEMutableRemove a resource
PATCHMutablePartially update a resource

All of these modify the server somehow.


🛠️ Quick Summary:

HTTP MethodImmutable (Safe)?
GET✅ Yes
HEAD✅ Yes
OPTIONS✅ Yes
TRACE✅ Yes
POST❌ No
PUT❌ No
DELETE❌ No
PATCH❌ No

⚡ Very simple memory trick:

If the methodThen
Only reads / asks✅ Immutable (safe)
Creates / updates / deletes❌ Not immutable (unsafe)
This entry was posted in Без рубрики. Bookmark the permalink.