6

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?

Bluefire
  • 13,519
  • 24
  • 74
  • 118
  • At the start there was only "GET", "POST" came after. – Analog May 25 '13 at 14:49
  • conventionnally, apart from the actual technical difference, GET is a call expecting an answer while POST is just data you're sending to the server. this link talks about that : http://javascript.about.com/od/ajax/a/ajaxgp.htm – Sebas May 25 '13 at 14:51
  • Your browser won't allow it because it's not a common action for end-users. Nothing prevents you from installing an extension to send these type of requests. – Overv May 25 '13 at 14:58
  • Although not a direct answer, take a look at the definitions within [REST](https://en.wikipedia.org/wiki/Representational_state_transfer). – Jared Farrish May 25 '13 at 15:16
  • Also: [idempotent (idempotency?)](http://stackoverflow.com/questions/1077412/what-is-an-idempotent-operation) Quoteth: *Idempotent operations are often used in the design of network protocols, where a request to perform an operation is guaranteed to happen at least once, but might also happen more than once. If the operation is idempotent, then there is no harm in performing the operation two or more times.* – Jared Farrish May 25 '13 at 15:18
  • You might also find this video really useful: http://www.youtube.com/watch?v=NEWTPFzt2-E – Jared Farrish May 25 '13 at 15:44

5 Answers5

7

Why, when the specifications for HTTP requests were being made, were the names "get" and "post" chosen?

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!)

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?

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.

Why can't I make a request that submits data to a server, and whose parameters can be seen in the address bar?

You can use an address which has a query string (GET parameters) as the target for a POST request - perfectly legal.

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
3

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.

Overv
  • 8,433
  • 2
  • 40
  • 70
  • 1
    Agreed, If you're going to downvote a question at least have the decency to explain your downvote... – Leo Correa May 25 '13 at 14:54
  • 1
    I'd love to hear why, too. His point is perfectly valid. AFAIK it's about semantics - GET intended to ask for data (potentially specify it with query) and POST intended to send back data. There's very little technical difference, apart from some restrictions enforced based on those semantics. +1 for justice! – Damyan Petev May 25 '13 at 14:56
2

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.

Nicolas Zozol
  • 6,910
  • 3
  • 50
  • 74
  • This says exactly the same as my answer, yet doesn't get downvotes. Can someone explain? – Overv May 25 '13 at 14:53
  • @Overv Probably because voters don't always take the time to read every other answer and make sure to vote in a consistent manner on each one. – pabrams Sep 04 '17 at 15:08
1

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...

Leo Correa
  • 19,131
  • 2
  • 53
  • 71
0

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.

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
  • Following semantics `POST` should be used when requesting the server to create a new resource. `PUT` or `PATCH` on the other hand can be used to create/update resources. – Leo Correa May 25 '13 at 15:03