L2. Describe the functioning of the HTTP protocol and summarize different versions Flashcards
What is HTTP?
The Hypertext Transfer Protocol (HTTP) is an application-layer protocol that serves as the basis of communication on the World Wide Web
When is HTTP used?
For example, when a web browser requests a resource from a server, HTTP is the protocol that is used
What model does HTTP operate on?
HTTP operates on a client-server model
What is a client-server model?
A model of interaction in which a process sends a request to another process and awaits a response. The requesting process is called a client and the responding process is called a server. The client process is usually a web browser
What are two terms that are frequently used to describe HTTP?
“Client-server model” and “stateless protocol”
What does it mean that HTTP is a stateless protocol?
HTTP being a stateless protocol means each request-response pair is independent from other requests and responses. The server does not retain information about previous requests from the same client
What is the structure of a HTTP request?
- Request line
- Headers
- Body (optional)
What does a HTTP request line contain?
The method of the request, the path of the requested resource, and the HTTP version used
Name some HTTP request methods
- GET - for requesting data from a resource without affecting the resource
- POST - for submitting data to a resource, resulting in a change on the server
- DELETE - for the deleting the specified resource
- PATCH - for applying partial modifications to a resource
What is the purpose of HTTP request headers?
To provide metadata about the request
When does a HTTP request have a body?
When some data is sent to the server, eg when the request method is POST
What is the structure of a HTTP response?
- Status line
- Headers
- Body
What does a HTTP response status line include?
The HTTP version, a status code, and a reason phrase
Name some HTTP response status codes and reason phrases
- 200 OK - request was successful
- 201 Created - request was successful and resource was created on the server
- 400 Bad Request - the server couldn’t understand the request
- 404 Not Found - the server couldn’t find the requested resource
- 500 Internal Server Error - an error occurred on the server
Name some examples of metadata provided in the HTTP response headers
Content-Type, Content-Length