Week 5 - HTTP and Javalin - Intro to HTTP and Javalin, Dependency Management with Maven Flashcards
What is HTTP?
HTTP stands for HyperText Transfer Protocol is used to send hypermedia over the internet
HTTP works by
making a connection to a server, sending a request, and receiving a response
A request contains
contains the method used, the endpoint, and optional headers and a body
A response contains
the status code, status message, and optional headers and a body
A body contains
a resource, which is just some data
HTTP Methods:
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs.
GET requests
GET method is used to retrieve data from a server at the specified resource. For example, say you have an API with a /users endpoint. Making a GET request to that endpoint should return a list of all available users.
POST requests
are used to send data to the API server to create or update a resource. The data sent to the server is stored in the request body of the HTTP request.
PUT requests
are used to send data to the API to update or create a resource.
Difference between PUT and POST requests
The difference is that PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result. In contrast, calling a POST request repeatedly may have side effects when creating the same resource multiple times.
PATCH request
you only apply partial modifications to the resource.
DELETE method (request)
delete the resource at the specified URL
HEAD method
is almost identical to GET, except without the response body
In other words, if GET /users returns a list of users, then HEAD /users will make the same request but won’t get back the list of users.
HEAD requests are useful for checking what a GET request will return before actually making a GET request – like before downloading a large file or response body. Learn more about HEAD requests on MDN.
OPTIONS request
should return data describing what other methods and operations the server supports at the given URL.
Informational responses
(100–199)