3

I had asked a related below question and from answers, I got a sense of why is there a notion of methods like GET,POST etc in http protocol:

What is the need of methods like GET and POST in the HTTP protocol?

This raises another question like how does browser know which HTTP method like GET,POST etc to use?. For example in gmail compose link, the PUT/POST request and data will be sent. How does the browser come to know which method to use? Does the gmail page sent by server include the method name to use when calling gmail compose request URL? when we call www.gmail.com , it must be using GET method, how does the browser know that this method to use?

Stephen Ostermiller
  • 99,822
  • 18
  • 143
  • 364
BioLogic
  • 173
  • 3

1 Answers1

4

In short, context.

Type a keyword that isn't a URL into the browser's search bar? Send a GET request to the default search engine with that keyword.

Type a URL into the browser's search bar? Send a GET request to the URL itself.

Click on a normal link on a web page? Send a GET request to the URL as specified by the href tag of the link.

Click on a form button on a web page? Send a POST request to the URL that you are currently on.

Click on a button that is handled by some ajax? Whatever that ajax code specifies.

Kent Shikama
  • 141
  • 2