HTTP METHOD Summary
A simple summary about the HTTP methods and not really systematic
The first question is how to understand the "What is idempotent?"
There is a very simple answer found from STACKOVERFLOW:
No matter how many times you call the operation, the result will be the same.
It's like a basic math function y=x+4 no matter how many times you call it f(4), it will give you the same answer 7.
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". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.
User's action will not make any change to the recourses in the server that means the action/method is safe
PS. in the real product server GET method sometimes associate with the backend Database and do some queries which may cause side-effect, the important distinction here is that the user did not request the side-effects.
HTTP Method History
HTTP 0.9 had a single method: GET.
HTTP 1.0 had the methods: GET, HEAD, and POST.
HTTP 1.1, the current version, has the methods: GET, HEAD, POST, OPTIONS, PUT, DELETE, TRACE, and CONNECT.
For proxy usage
DELETE /file.html HTTP/1.1
get meta-info/header of resources, for example use HEAD to get the file size before downloading it.
HEAD has no response content(should be ignored even it exists)
get the options that the server accept/support
similar to upload and replace the resources in the server
this method is Idempotent
use GET method to get specific info from server, if the info associate with the generation of info itself then the result should be return in the response content
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header.
A POST request is typically sent via an HTML form and results in a change on the server.
|Request has body||No||May||NO||NO||YES||NO||YES|
|Successful response has body||Yes||May||NO||YES||NO||YES||YES|
|Cacheable||No||No||YES||NO||NO||YES||Only if freshness info is included|
|Allowed in HTML forms||No||No||NO||NO||NO||YES||YES|