-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Build Your Own Web Framework in Elixir
By :

HTTP is an application layer protocol that provides communication standards between clients (such as web browsers) and web servers. This standardization helps browsers and servers talk to each other as long as the request and the response follow a specific format.
An HTTP request is a text document with four elements:
GET
is used to retrieve resource information, whereas POST
is used to send new resource information as a form.Here’s an example of an HTTP request document:
GET / HTTP/1.1 Host: localhost:8080 User-Agent: curl/7.75.0 Accept: */* Body of the request
As you can see, the preceding request was made with the GET
method to localhost:8080
with the body, Body of
the request
.
Similarly, an HTTP response contains four elements:
2XX
status codes are used for a successful response, whereas 4XX
status codes are used for errors due to the request.The following is an example of an HTTP response document:
HTTP/1.1 404 Not Found content-length: 13 content-type: text/html server: Cowboy 404 Not found
The preceding response is an example of a 404 (Not found)
response. Notice that content-length
shows the number of characters present in the response body.
Now that we know how HTTP facilitates client-server communication, it is time to build a web server using Cowboy.