Get
Post
- Get requests are used to retrieve data from the server
- Query parameters are sent as part of the url (www.blah.com?name=alexandra). However there is a maximum length restriction of 2048 on urls so the amount of data that can be sent in the url is limited.
- Get requests can be bookmarked. This is because a bookmark is just a url and the url of a get request contains all the data required for the server to return the same data again.
Post
- Post is used to send data to the server. Because post requests are not idempotent (ie because they can modify the server state), post requests cannot be cached.
- Query parameters are sent in the message body rather than in the url
- Post requests cannot be bookmarked. As we read earlier a bookmark is just a url. If you save the url of a post request so if you try to revisit the url of a post request the server won't know how to respond.
Head
- This is very similar to a get request but only the headers are returned, not the message body.
Put
- Put is used to for 'create' operations.
- Post can be used to 'create' on the server, but the difference between them is that put is idempotent. Put requests either create or overwrite existing resources.
No comments:
Post a Comment