简体   繁体   中英

Use of HTTP Post method?

Below is the statement written at http://hateinterview.com/java-script/methods-get-vs-post-in-html-forms/1854.html

By specification, GET is used basically for retrieving data where as POST is used for data storing, data updating, ordering a product or even e-mailing

Whenever i used get or post method, i used them to get the parameters with getparameter() method of httprequest. I did not get in above statement, how post method is used for datastoring or dataupdation which we cant achieve with get method. Looking for a very brief example.

EDIT: Thanks all for your answers but i am specifically looking for meaning of data storing, data updating in post method apart from file loading stuff.

GET can in theory also store and update data, but it's simply not safe. It's too easy to accidently store or update data by just bookmarking it, following a link or being indexed by a searchbot. POST requests are not bookmarkable/linkable and not indexed by searchbots. Also, the GET query string has a limited length, the safe limit is 255 characters. The POST request body can however be as large as 2GB. Also, uploading files is not possible by GET.

One difference is that the GET data (in the URL, as another answer says) show up at a *nix server as the contents of the environment variable QUERY_STRING , whereas POST data appear on stdin . Regardless of how they are packaged and sent, GET and POST data are identical in format, in my experience.

@Mohit edited his question to add: "Thanks all for your answers but i am specifically looking for meaning of data storing, data updating in post method apart from file loading stuff. "

Read , specifically Sections and : ,特别是

"The GET method means retrieve ... information."

"The POST method is used to request that the origin server accept" information.

To be strictly compliant with rfc2616, use the GET method to read data from the server. Use the POST method to write data to the server.

The "meaning of data storing, data updating" is exactly that. How could this possibly be any clearer or more explicit?

POST sends the data in the body while GET puts the data in the URL...

For example to upload a file you use POST... since GET puts the data into URL the data is visible to the user and the length is limited.

see for example http://www.cs.tut.fi/~jkorpela/forms/methods.html

there are things you can not do with GET !
first of them is with post you can upload files!
See this: Article or this one

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM