Reputation: 14119
Why, when the specifications for HTTP requests were being made, were the names "get" and "post" chosen? How is whether I want parameters to be hidden or not at all relevant to whether I'm retrieving data from a server or submitting it?
EDIT: Let me reformulate. I know what a GET and POST request is. What I want to know is, why can't I make a request that submits data to a server, and whose parameters can be seen in the address bar?
Upvotes: 6
Views: 1900
Reputation: 300855
GET came first - it was the only verb supported in the original HTTP protocol - we can only speculate why POST was chosen. Perhaps because it is evocative of putting something (the post body) into an envelope (the HTTP request) and putting it into a postbox (the HTTP server!)
It isn't about "hiding parameters", it's to draw a distinction between requests which have a side effect, and requests which do not.
See RFC2616 section 9.1 for the details, but in summary...
In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe".
So, while you can make a GET request submit data, repeating that same request should not have any other side effect, otherwise what you're doing isn't really HTTP.
You can use an address which has a query string (GET parameters) as the target for a POST request - perfectly legal.
Upvotes: 7
Reputation: 19799
To answer your updated question...Sure, you can do whatever you want in terms of send requests and receiving data.
It's all about how you implement your server code to handle it. Write a URL that has data on the query string use a GET request (browser purposes), then handle the creating of whatever it is you want to create on the server end.
This is of course breaking HTTP specifications as many people here have quoted.
You can even go as far as making an AJAX request that uses POST with some data in the body as well as the query string and handle whatever you need to do in the server end.
Again, submitting data to the server is possible using a GET
request and it will be visible by the address bar. You may choose to use that data however you wish on your server code and its up to you whether you want to abide by HTTP specs or not.
EDIT Also, what kind of data are you talking about? Do you want to send a file through the address bar? I don't remember exactly what the length limit for the URL/Query string is but I'm sure binary data wouldn't play nice with it...
Upvotes: 1
Reputation: 7038
You use a GET when you want to ... GET datas, and POST when you send datas to the server, just like you would POST a letter to your boss.
It's not possible with Web Forms, but with a full Http client, you can also use the verbs DELETE to delete a resource, HEAD to get metadata headers, and probably the worst name is PUT to update datas.
In all these kind of requests, data are not hidden at all. They are just not shown on most browser, but you can see them in command line tools such as curl, or web developpers tools.
Upvotes: 2
Reputation: 68935
Whether data is hidden or not is feature rather a than specification. Do not associate it with the request specifications. They are designed that way and that is it. It is just that when you use GET data is sent from URL unlike POST method. After all it's programmers choice and requirement that decides which request he must use.
Get request is used to get data from server where as POST request is used to post data to server.
If you look at Wiki
GET requests a representation of the specified resource. Note that GET should not be used
for operations that cause side-effects, such as using it for taking actions in web
applications. One reason for this is that GET may be used arbitrarily by robots or
crawlers, which should not need to consider the side effects that a request should cause.
and
POST submits data to be processed (e.g., from an HTML form) to the identified resource.
The data is included in the body of the request. This may result in the creation of a new
resource or the updates of existing resources or both.
So essentially GET
is used to retrieve remote data, and POST
is used to insert/update remote data.
Upvotes: 0
Reputation: 8529
When you're sending a GET request, you generally send little data to the server and get a lot back. It's the other way around with a POST request. That's why you usually don't want to see all that data.
Upvotes: 3