HTTP Request Process
A complete HTTP request process includes DNS requests and responses, domain name resolution, TCP connection, three-way handshake, server response to the HTTP request, browser parsing and rendering of HTML, and finally, the server closes the TCP connection with a four-way handshake.

Step 1: DNS Resolution
The local DNS uses recursive queries to resolve domain name records. For example, specifying a telecom DNS to resolve ipw.cn, you can see the A record for ipw.cn directly returned in the <span><span>ANSWER SECTION</span></span>.
The local DNS does not store domain name resolution records but forwards requests to authoritative DNS servers for recursive queries, returning the resolution records to the client. However, it does cache resolution records.

First, the PC will search the browser’s own DNS cache, which has a short cache time of about 1 minute and can only hold 1000 entries. If the browser’s cache does not contain the record, it will search the system’s DNS cache and also check the hosts file. If none of these three processes find the record, it will recursively query the domain name server as shown in the diagram above. Local DNS queries are recursive, while domain server queries are iterative. DNS optimization includes two aspects: DNS caching and DNS load balancing.
In the authoritative DNS, taking the query for ipw.cn as an example, the roles of the three-level DNS are:
1. Root DNS: For example, a.root-servers.net., responsible for returning the resolution record of the top-level DNS for the queried domain, 203.119.25.1;
2. Top-Level DNS: For example, a.dns.cn., responsible for returning the DNS address of the queried domain, such as ns3.dnsv2.com., which is registered in the top-level domain server and can be modified in the domain management platform through the whois command.
3. Primary DNS: For example, ns3.dnsv2.com., responsible for returning the specific domain’s resolution record, such as the A record for ipw.cn being 106.55.75.123.
Below is how to view the A record of the root DNS

Step 2: TCP Connection – Three-Way Handshake
To ensure a reliable connection between the client and server, TCP must perform a three-way handshake when establishing a connection. The purpose of the three-way handshake is to confirm whether both parties’ receiving and sending capabilities are normal.
First Handshake
The TCP client process first creates a Transmission Control Block (TCB) and then sends a connection request message to the server. This message has the SYN=1 flag set in the header and selects an initial sequence number seq=x. At this point, the TCP client process enters the SYN-SENT state.
Second Handshake
After receiving the request message, if the TCP server agrees to connect, it will send a confirmation message back to the client. The confirmation message should have ACK=1, SYN=1, an acknowledgment number ack=x+1, and it will also initialize its own sequence number seq=y. At this point, the TCP server process enters the SYN-RCVD state.
Third Handshake
After the TCP client receives the confirmation, it must send a confirmation back to the server. The confirmation message has ACK=1, ack=y+1, and its own sequence number seq=x+1. At this point, the TCP connection is established, and the client enters the ESTABLISHED state, completing the three-way handshake.
Step 3: Initiating an HTTP Request
The HTTP request message consists of three parts: request line, request headers, and request body.
Request Line: Describes the client’s request method, the resource name being requested, and the version of the HTTP protocol being used.
Request Headers: Describe which host and port the client is requesting, as well as some environmental information about the client.
Request Body: When using methods like POST, the client typically needs to send data to the server. This data is stored in the request body.
For example, using a POST request with the Axios library in JavaScript to send JSON data:
const axios = require('axios');
// Data object
const postData = {
email: 'user1',
password: 'pass123'
};
// POST request configuration
axios.post('https://api.example.com/data', postData, {
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
There are many HTTP request methods, some of the most common include:
- GET: Request a complete resource
- HEAD: Request only the response headers
- POST: Submit a form
- PUT: Upload a file
- DELETE: Delete a resource
- OPTIONS: Return the methods supported by the requested resource
- TRACE: Trace the path taken by a request to a resource through proxies.
- URI: Uniform Resource Identifier
- URL: Uniform Resource Locator
- URN: Uniform Resource Name