HTTP and Rest - sarahduv-401-advanced-javascript/seattle-javascript-401d32 GitHub Wiki

HTTP and Rest

What does HTTP stand for?

Hypertext Transfer Protocol

What are the basics?

  • HTTP allows for communication between a variety of hosts and clients, and supports a mixture of network configurations.
  • Communication between a host and a client occurs, via a request/response pair.
  • The client initiates an HTTP request message, which is serviced through a HTTP response message in return.

Request verbs

  • GET: fetch an existing resource. The URL contains all the necessary information the server needs to locate and return the resource.
  • POST: create a new resource. POST requests usually carry a payload that specifies the data for the new resource.
  • PUT: update an existing resource. The payload may contain the updated data for the resource.
  • DELETE: delete an existing resource.

Status codes

  • 100's: Informational
  • 200's: Successful
  • 300's: Redirection
  • 400's: Client error
  • 500's: Server error

Rest differences

  • REST is a simple way to organize interactions between independent systems. It's been growing in popularity since 2005, and inspires the design of services, such as the Twitter API. This is due to the fact that REST allows you to interact with minimal overhead with clients as diverse as mobile phones and other websites. In theory, REST is not tied to the web, but it's almost always implemented as such, and was inspired by HTTP. As a result, REST can be used wherever HTTP can.

Sources: https://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177 https://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340