Front-End-Development

HTTP

What is HTTP?

HTTP is a core operational protocol of the world wide web. It is what enables your web browser to communicate with a web server that hosts a website. HTTP is the communication protocol you use whenever you browse the web. HTTP stands for Hypertext Transfer Protocol. It is a protocol used for transferring web resources such as HTML documents, images, styles, and other files.

An HTTP request line consists of a method, path, version and headers.

GET /home.html HTTP/1.1

In this example, GET is the HTTP method, /home.html is the resource requested and HTTP 1.1 is the protocol used.

The most commonly used HTTP protocol is Versions 1.1 and 2.0

HTTP methods

The primary or the most commonly used HTTP methods are, GET, POST, PUT, and DELETE.

HTTPS methods Description
Get The client requests a resource on the web server.
POST The client submits data to a resource on the web server.
PUT The client replaces a resource on the web server.
DELETE The client deletes a resource on the web server.

HTTP request headers

After the HTTP request line, the HTTP headers are followed by a line break. A header is a case-insensitive name followed by a: and then followed by a value.

Common headers are:

Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en
Content-type: text/json

The Host header specifies the host of the server and indicates where the resource is requested from.

The User-Agent header informs the web server of the application that is making the request. It often includes the operating system (Windows, Mac, Linux), version and application vendor.

The Accept header informs the web server what type of content the client will accept as the response.

The Accept-Language header indicates the language and optionally the locale that the client prefers.

The Content-type header indicates the type of content being transmitted in the request body.

HTTP response code

Response code 1-2 Response code 3-4 Response code 5

Other Internet protocols

Hypertext Transfer Protocols (HTTP) are used on top of Transmission Control Protocol (TCP) to transfer webpages and other content from websites. This reading explores other protocols commonly used on the Internet.