Sunday, 1 June 2014

Overview of Http Requests

Get

  • 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. 
Head request example usage: This would be useful for client side caching. The client issues a get request initially and caches the response. Then, if the client wants to request the same thing again, it can first issue a head request to get the last modification date of the response to determine whether or not the cached data is up to date. 


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

Scala with Cats: Answers to revision questions

I'm studying the 'Scala with Cats' book. I want the information to stick so I am applying a technique from 'Ultralearning...