What happens after we type a web address into the browser? It is a common interview question for web developers. You can find a detailed answer to this question on GitHub. The main thing the interviewer wants to know is your level of understanding of HTTP. In this lesson, we'll cover this topic in more detail.
What is HTTP
To better understand this term, let's remind ourselves what a protocol is. It's a set of conventions or rules by which different programs can exchange information. One of the most common web protocols is HTTP (Hypertext Transfer Protocol). It is a set of rules that both your computer and a computer located far away will know. These rules help the browser and the web server communicate with each other.
You already know that a web server is a program installed on a server and handles incoming connections. A web server works in two stages:
- The server receives information from the browser about which page of which site we want to load
- The server then returns the contents of this webpage to the browser
This request-response cycle is an HTTP session. Now, we will use the curl program to see what it looks like:
curl -v --head https://hexlet.io
* Trying 174.66.43.105:443...
* TCP_NODELAY set
* Connected to hexlet.io (174.66.43.105) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com