Mastering HTTP Methods: A Practical Guide for every developer

Think of HTTP methods as the verbs of the web (like to get something, to post something)—they tell the server what action you want to take on a resource. Whether you’re fetching data with GET, sending form data with POST, or updating something with PATCH or PUT, each method has a clear purpose. Today in this post you are going to mastering http methods .

1: GET method

The GET method is used to request data from a server without making any changes to it—essentially, it retrieves resources like HTML pages, images, or API data (think about it as when you enter a url in browser address bar manually, then it performs a get request). One key characteristic of GET is that the data sent with the request is appended to the URL as query parameters (after ? in key=value pair), making it visible in the browser’s address bar (e.g., example.com/search?query=value).

Because of this, it’s not ideal for sensitive data. It is very fast compared to other methods like POST, because it doesn’t have a request body and is usually cached by browsers or servers. The get method should be used when you’re retrieving data without side effects—such as loading a webpage, searching, or pulling information from an API.

Here’s a simple example using an HTML form that sends a GET request:

<form action="/search" method="GET">
  <input type="text" name="query" placeholder="Search...">
  <button type="submit">Search</button>
</form>

2: HEAD method

The HEAD method is similar to GET, but it only retrieves the headers of a resource like content-type, body size, status code—not the actual body/content. Its main purpose is to check what a GET request would return, without downloading the entire response. Since it doesn’t include a response body, it’s typically not visible in the URL, though it behaves like a GET in that it uses the URL to request data.

It is natively supported in browsers, although not usually triggered by typical user actions (you’d use it more with tools or scripts like postman or javascript). It’s faster than GET, especially for large files, since only metadata is retrieved. Use HEAD when you need to check for resource availability, content type, or modified date without downloading the file. HTML forms don’t support HEAD directly, but it can be used via tools like fetch in or Postman.

3. POST method

The POST method is used to send data to a server to create or process a resource, such as submitting a form or uploading a file. The data is included in the request body, so it is not visible in the URL.

It is fully supported by browsers and commonly used when submitting HTML forms. It’s a bit slower than GET, due to the extra data handling, but it’s more secure for sensitive data. Use POST when you’re creating new resources, logging in, or handling any action with side effects on the server.

Example with an HTML form:

<form action="/submit" method="POST">
  <input type="text" name="username" placeholder="Enter username">
  <button type="submit">Submit</button>
</form>

4: OPTIONS method

The OPTIONS method is used to describe the communication options available for a specific URL or server, without initiating an actual resource request. On success it generally response with 200 or 204 status code. It’s mainly used in CORS (Cross-Origin Resource Sharing) to check if certain HTTP methods are allowed.

There’s nothing visible in the URL, and it’s not something users trigger manually in a browser—it’s handled natively by browsers behind the scenes, especially in cross-origin requests (when you perform a request from one domain to another domain). It’s generally fast and lightweight. Use OPTIONS when you need to check what actions or headers are allowed for a given endpoint. Not usable directly via HTML forms but can be triggered using postman client or javascript using fetch.

If you are still reading then absolutely you really want to polish your concept knowledge. But don’t worry as I assured to you after reading full post your will feel like a mastering http methods. Keep Reading

5. TRACE method

The TRACE method is used to troubleshoot what’s happening along the path between client and server, by echoing back the received request including path, body, method protocol version etc. It works like a debugging technique that returns the exact request sent. It does not change server state, and there’s nothing visibly sent via the URL aside from the path.

TRACE is rarely used and often disabled for security reasons, as it can expose sensitive data in certain scenarios. It’s supported in the HTTP spec but not commonly triggered via browser UI.

Use TRACE when debugging request behavior between client and server, but do so with caution as it can expose sensitive information. It’s not usable in HTML forms and Browsers won’t let you call TRACE via JavaScript (fetch or XMLHttpRequest) for security reasons, and it’s also removed from postman so you have to manually type it.

6. PUT method

The PUT method is used to update or completely replace a resource at a specific URL. Unlike POST, which adds a new resource, PUT sends the full updated version. The data is sent in the body, so it’s not visible in the URL. PUT isn’t triggered directly via browsers like get or post, but it’s supported through tools and JavaScript (fetch, axios, etc.). It’s usually faster than PATCH, as it sends a full replacement, but potentially slower if the payload is large. Use PUT when you want to replace an entire object or record, like updating a user’s profile. It’s not usable via standard HTML forms without JavaScript but few frameworks support it by tweaking.

7: DELETE method

The DELETE method is used to remove a resource from the server. It targets a specific URL and expects the server to delete that resource. Like PUT, it sends data in the body (optionally), and is not visible in the URL.

DELETE is not natively used in browser actions like get and post, but can be triggered via JavaScript. It’s generally fast, assuming the server doesn’t perform extra checks.

Use DELETE when you need to remove a resource, like deleting a post or user account. It’s not usable with HTML forms directly—requires JS or HTTP client.

8: PATCH method

The PATCH method is used to partially update a resource, sending only the fields that need changes like only update profile of user account. This makes it more efficient than PUT when only small updates are needed. The data is in the request body, and not visible in the URL. PATCH is not supported directly in HTML forms, but fully supported through JavaScript. It’s faster than PUT for partial updates, and great for optimizing API calls.

Use PATCH when you need to update just a part of a resource, like changing a user’s email without touching their entire profile.

9: CONNECT method

The CONNECT method is used to establish a tunnel to a remote server, typically used with HTTPS via a proxy. It’s not for typical API or web app usage. The CONNECT method works at a lower level and isn’t visible in URL form, nor is it triggered by users directly.

It’s natively supported by browsers under the hood when using secure connections by creating a tunnel. Speed depends on connection quality. You’ll use CONNECT in proxy or VPN scenarios, not typical web dev, and it’s not used with HTML forms at all.

If you still reading and reached there. Here is the bonus summary for everything that you have read. After that you feel like confidence of a master of these http method.

Bonus Tips:

I. GET

  • Purpose: To retrieve data from the server without changing anything.
  • Think: “Give me this information.”
  • HTML supports directly: Yes

II. HEAD

  • Purpose: To check the metadata of a resource (like headers), without downloading the actual content.
  • Think: “Is this resource there? What are its details?”
  • HTML supports directly: No, but can be triggered by javascript or api client

III. POST

  • Purpose: To submit data to the server and create a new resource or trigger a processing action.
  • Think: “Here’s some data—do something with it.”
  • HTML supports directly: Yes

IV. PUT

  • Purpose: To replace an existing resource entirely with the data sent.
  • Think: “Overwrite this with the new version.”
  • HTML supports directly: No, but can be triggered by javascript or api client

V. PATCH

  • Purpose: To partially update an existing resource.
  • Think: “Just change this one part.”
  • HTML supports directly: No, but can be triggered by javascript or client like postman

VI. DELETE

  • Purpose: To remove a resource from the server.
  • Think: “Delete this, please.”
  • HTML supports directly: No, but can be triggered by javascript or api client

VII. OPTIONS

  • Purpose: To ask the server what it supports, like allowed methods or headers.
  • Think: “What can I do here?”
  • HTML supports directly: No, but can be triggered by javascript or api client

VIII. TRACE

  • Purpose: To echo the request back, used for debugging what was received.
  • Think: “Show me what you got from me.”
  • HTML supports directly: No, and it’s blocked by browser and proxies generally

IX. CONNECT

  • Purpose: To create a tunnel to another server, often for SSL/HTTPS connections via a proxy.
  • Think: “Let me securely connect through you.”
  • HTML supports directly: “No, not for the browser it’s for digging tunnel to connect securely like a VPN or proxy does”

And finally you reached the end of the post. Leave your reaction, Share, Comment I hope you have got a clear idea about this method. Let’s meet in my next post.

Till then By by.

Share and Enjoy !

Shares
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x