Hypertext Transfer Protocol (HTTP)
Learn about the Hypertext Transfer Protocol (HTTP) and its importance in APIs.
Introduction
The Hypertext Transfer Protocol (HTTP) is a
HTTP is based on the concepts of request and response, where one program (the client) requests another program (the server), and the server returns a response. The client usually makes requests in the form of HTTP commands, and the server responds with data in the form of documents. These commands are structured by different API architecture styles that we'll discuss in the coming chapters. Because it’s a driving force for APIs, HTTP is an essential protocol to understand.
As long as the request conforms to HTTP standards, the server will respond with the requested resources, regardless of the type of client.
This lesson discusses the essentials of HTTP. First, we explain its request and response formats. Next, we look into the HTTP methods, response status codes, and different HTTP headers. Toward the end, we discuss the significance of HTTP in APIs. Finally, we explain the secure version of HTTP, which is HTTPS.
HTTP message flow
As discussed in the previous section, HTTP communication is initiated by the clients sending a request to the server, and the server responds. This section discusses the request and response message structure. The server parses each request to interpret the request and generate the response. In the same way, the client parses the received response from the server and collects the desired application data from the response message.
HTTP request structure
An HTTP request message is composed of the following four components:
Method: HTTP provides built-in methods that determine what kind of ...