HTTP and REST Readings - mwilkin-401-advanced-javascript/bend-javascript-401d2 GitHub Wiki

What is HTTP and REST? Well, HTTP or Hypertext Transfer Protocol, is essentially the foundation of interweb communication. HTTP is a stateless protocol which assumes very little about any particular system and communication occurs between a client and host via a request/response pair. The request message is sent via a URL (Uniform Resource Locator) which has the following components: a protocol (http or https for secure communication), a host (www.host.com), a port (1234), a resource path (path/to/resource) and a query (or search term, a=b&x=y).

The actioned that is going to be performed is specified by using one of a set of specific verbs. There are several actions but the most fundamental are: GET: go get a an existing resource. POST: create a new resource. PUT: update an existing resource. DELETE: deletes and existing resource.

The responses to a request have a variety of codes which are status codes that tell the client how to interpret the response. 1xx : Information Message: it tells the client to continue sending the remainder of the request. 2xx : Successful: the request was successfully processed. 3xx : Redirection: requires the client to take additional action. 4xx: Client Error: indicates that the server thinks the client made an improper request. 5xx : Server Error: indicates a server failure while processing the request.

The request and response messages have particular formats: These can include general headers, request specific headers, response specific headers and entity headers. There is a variety of information which is carried in these headers which can include meta-information, they can act as modifies (eg request header modify the the request message).

There are many tools which help monitor HTTP traffic such as Chrome/Webkit inspector. They can be used to debug error and monitor traffic/transfer speeds.

Finally, REST or REpresentational State Transfer, is a standardized way for computers to communicate and transfer information with each other over the web.