大网数据广告活动
网站运营与故障问答

How does browser know which HTTP method like GET,POST etc to use?

· 52CE 我爱测

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 …

问题原文

原帖链接 · BioLogic · CC BY-SA 4.0

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?

社区高分解答

原帖链接 · Kent Shikama · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-09-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。