Aug 03, 2025
Differences in HTTP Request Responses
Differences in HTTP Request Responses (with Testing Examples)
HTTP responses vary depending on the request method, protocol version, and headers. Understanding these differences helps developers debug and optimize communication between clients and servers.
This guide explains how different HTTP requests behave, when connections close or stay open, and how to test them.
Differences in HTTP Requests and Responses
| Request | Response Contains Headers? | Response Contains Body? | Connection Closes? | Notes |
|---|---|---|---|---|
GET / HTTP/1.0 |
✅ Yes | ✅ Yes | ✅ Yes | HTTP/1.0 closes by default unless Connection: keep-alive is used. |
GET / HTTP/1.1 + Connection: close |
✅ Yes | ✅ Yes | ✅ Yes | Connection explicitly closed by server. |
GET / HTTP/1.1 (no Connection header) |
✅ Yes | ✅ Yes | ❌ No | HTTP/1.1 keeps connections alive by default. |
GET / (minimal/invalid HTTP/0.9) |
❌ No | ✅ Yes | ✅ Yes | Treated as HTTP/0.9; only body is returned or request rejected. |
HEAD / HTTP/1.0 |
✅ Yes | ❌ No | ✅ Yes | HEAD only returns headers; connection closes by default. |
HEAD / HTTP/1.1 + Connection: close |
✅ Yes | ❌ No | ✅ Yes | Same as above, with explicit closure. |
HEAD / HTTP/1.1 (no Connection header) |
✅ Yes | ❌ No | ❌ No | Connection remains open (persistent). |
Explanation of Key Differences
HTTP/1.0:
- No persistent connections by default.
- Closes after every request unless
Connection: keep-aliveis specified.
HTTP/1.1:
- Persistent (keep-alive) connections by default.
- Requires a
Host:header to be valid. - Closes only when
Connection: closeis sent or the server enforces it.
HEAD Requests:
- Always return headers only (no body).
- Useful for checking resource existence and metadata without downloading content.
Minimal HTTP Requests (HTTP/0.9 style):
- Rarely supported by modern servers.
- If accepted, the response usually includes only the body and closes immediately.
Testing These Requests Yourself
You can test these behaviors with simple command-line tools:
1. Using Netcat (nc) – For Plain HTTP (Port 80)
1 | echo -e "HEAD / HTTP/1.0\r\n\r\n" | nc example.com 80 |
- Works for unencrypted HTTP.
- Shows headers, then the server closes the connection.
2. Using OpenSSL (openssl s_client) – For HTTPS (Port 443)
1 | echo -e "HEAD / HTTP/1.0\r\n\r\n" | openssl s_client -connect example.com:443 |
- Establishes a TLS handshake, then sends your raw HTTP request.
- Useful for debugging HTTPS responses manually.
For a GET request:
1 | echo -e "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n" | openssl s_client -connect example.com:443 |
3. Using Curl (Simplest)
1 | curl -I https://example.com |
- Sends a HEAD request (
-Iflag). - Automatically handles HTTPS and displays headers only.
Conclusion
- HTTP/1.0: Closes connections unless asked otherwise.
- HTTP/1.1: Keeps connections alive unless
Connection: closeis specified. - HEAD: Returns only headers, never a body.
- Minimal HTTP/0.9 requests may behave unpredictably on modern servers.
💡 Tip: Use openssl s_client or curl -v for capturing and analyzing real server responses to fully understand how servers handle your requests.
🔜 Coming Next: A deep dive into persistent vs. non-persistent connections and how keep-alive impacts web performance.
Other:
Cheap VPS Recommendations Page: