技术问询:发起HEAD请求是否仍需执行TCP三次握手?
Absolutely—yes to both questions. Let’s break this down in plain terms:
- First, remember that all HTTP methods (GET, HEAD, POST, PUT, etc.) sit on top of TCP. TCP is a connection-oriented protocol, which means a reliable, established connection between client and server is non-negotiable before any application-level data (like an HTTP request) can be sent.
- The TCP three-way handshake (SYN → SYN-ACK → ACK) is the mandatory process to set up this connection. There’s no shortcut here for any HTTP request, including HEAD. Your client will still fire off the initial SYN packet to the server, wait for the server’s SYN-ACK response, then send an ACK packet to lock in the connection. Only after this handshake wraps up will your HEAD request actually be transmitted.
The only difference between HEAD and GET lives at the HTTP layer: a HEAD request asks the server to return just the response headers (not the resource body) for a given URL. But this doesn’t alter anything at the TCP level—TCP doesn’t care what kind of HTTP request you’re sending; it only ensures the connection is stable before passing data between client and server.
Once the HEAD request is processed and headers are sent back, the connection will either stay alive (if Connection: keep-alive is enabled) or close via the TCP four-way handshake, just like any other HTTP interaction.
内容的提问来源于stack exchange,提问作者m.a.d.cat

