HTTP stands for "HyperText Transfer Protocol". It is a set of rules for transferring data between the client and the server. It is just one of several Transfer Protocols like FTP (File Transfer Protocol), TCP (Transmission Control Protocol), and SMTP (Simple Mail Transport Protocol). Most protocols have a version with an "S" (HTTPS, SFTP) which stands for "secure" which means that the transfer is encrypted before it's sent.
What is an HTTP request and how does it work? show answer
An HTTP request is any web request made using HTTP (or HTTPS).
Whenever you click on a link, or do a Google search, or do pretty much anything on the internet, you're probably making an HTTP request. An HTTP request is typically made by a client to a server. Servers can also make HTTP requests to other servers but it is not possible to make an HTTP request to a client.
An HTTP request consists of a request header and request body. The header contains meta information about the request, like what type of request it is (request method), where it came from, who is allowed to see it, and a status code indicating what the result was (did it succeed, fail, etc).
The request body contains the substantive information in the request; basically the data being transferred like some parameters detailing what you need from a server, or the complete HTML data containing the webpage you're attempting to view.
HTTP requests come in one of several request methods. The four most common ones are GET, POST, PUT, and DELETE. Of these GET and POST make up the vast majority of the requests made across the web.
A client is anything making a request to a server. In most cases, the client is a browser like Chrome, Firefox, or Safari. But clients can also be other programs on your laptop (like Mail or Excel), hardware devices (like printers, Amazon Alexa, or the navigation system in a car), or even other servers (using a library like cURL). If it makes a request to a server, we call it a "client".
A server is any software that receives and processes network protocol request (like HTTP, TCP, FTP etc.). Servers are simply physical or virtual computers on which specialize software has been installed to receive network protocol requests from clients and return a response.
DNS stands for Domain Nname Server. This is a specialize type of server that processes requests for a domain (like www.melissadiaz.com). When you register a domain, that registration information is stored on a DNS server. The DNS server's main job is to maintain a huge database of domain names and their associated IP address. When you put www.melissadiaz.com in the browser and press Enter, the request goes to a DNS server to get the IP address for that website.
URL stand for Uniform Resource Locator - it is the "address" you put in the browser address bar to request a webpage or resource.
URLs are composed of a Protocol, subdomain, domain or "root domain", domain extension, path, and query string.
For the URL https://www.melissadiaz.com/shows/march?date=12&love=you, the https is the protocol, the www is the subdomiain, the melissadiaz is the domain, the .com is the domain extension, the /shows/march is the path, and everything after the ? is the query string.
The query string can be further broken down into individual parameters, in this case date=12 and love=you. The query string is typically used to pass extra information along with the URL and is associated the the HTTP GET request method.
The IP (Internet Protocol) address is set of numbers like 184.108.40.206 that is assigned to every device connected to the internet. It acts as a unique identifier for that device or resource the way a physical address like "345 Bragg st. Brooklyn, NY" uniquely defines a location in the physical world. All websites you visit are accessed using an IP address. The domain name is really just a proxy used for aesthetic purposes and the DNS (domain name server) keeps track of what the IP address is for every domain name.
The most common type of IP address is IPv4, which stands for "IP version 4". IPv4 are the typical IP addresses like 220.127.116.11 or 123.653.12.0 and consist of four groups of up to three numbers. If you do the math, you will find that there are 4,294,967,296 IPv4 addresses possible. That seems like alot, but given that every device on the internet needs a new and unique IP address, this number is not sufficient. Therefore, IPv6 was created (they skipped IPv5), which consists of 128bit hexidecimal system which looks like 2001:0db8:0000:0042:0000:8a2e:0370:7334. There are 10^28 number of IPv6 addresses possible so we're not going to run out for a long time.
Explain what happens when you make a request to a web server. show answer
When you visit a website (i.e. request a webpage using a URL) you make a request from your client (the browser) to a web server (some other physical or virtual computer somewhere out there in the world).
The request starts with the URL (like https://www.melissadiaz.com/about). When you put the URL in the address bar and press Enter, the browser parses the URL to figure out what kind of request you're trying to make (the protocol), what domain name you are making it to (the subdomain, root domain, and path), and whether there are any parameters you will be sending along with your request (the query parameters). The browser then uses this information to compile a request in the correct format, including the appropriate request headers and request body. The browser then needs to figure out the IP address of the domain name you provided. The ultimate record of truth for every domain name's IP address is the Domain Name Server (DNS), but since making a request to the DNS for every requests made on the internet every time would be inefficient, the browser can usually find the IP address stored in one of several cached data sources. Once the browser has the IP address, it encodes the request using the provided protocol and sends it over the internet.
The request will ideally be received by a web server (although you can make a request to some IP address with no configured server on the other end, in which case, it'll just time-out). Once the web server receives the request, it will hopefully be running some software (like PHP or NodeJS) that is able to interpret the request and return some coherent response. The server will also read the headers of the request to make sure it is allowed to accept a request from that source. If the source of the request is not allowed, it will return the appropriate response code. Otherwise, in the case of a request for a webpage, the server will parse the request using the path and query parameters and run whatever code (written by some back-end developer) applies for this particular request. If the code results in some output being printed, that raw text data will be appended to the response body. Finally, the response will be, once again, encoded using the appropriate protocol and returned to the request origin (your browser - via it's IP address). The response will have it's own headers, response body, and the applicable response code (200 for a successful request).
Types of Network Protocols
HTTP Request Methods
Everything about HTTP requests
Really cool comic strip explaining how DNS works
Anatomy of a URL
We're running out of IPv4 addresses
What happen to IPv5?
What happens when you make a web request
HTTP response codes