MINOR: http: do not close connections anymore after internal responses
Since we dropped support for legacy mode, it's not the stream which
deals with the connection but the mux, and there's no point in closing
the client connection after most internal status codes. For example if
the client gets a 401 or a 503 because a server doesn't respond, it
makes no sense forcing the connection to close after reporting this
status, because it's already done by the mux if the client asks for it
or is not compatible with keep-alive. This current state was inherited
from the early days but is still limiting the amount of client-side
connection reuse in a number of circumstances (typically server-side
errors). This change was planned for 2.1 but forgotten.
The status codes for which the connection is not closed anymore are those
that do not depend on the client side connection itself, which are all
except 400 and 408. This could be backported to 2.1 but not further, in
order to make sure legacy and HTX behave strictly similarly.
diff --git a/src/http.c b/src/http.c
index f8d7876..b798c5d 100644
--- a/src/http.c
+++ b/src/http.c
@@ -179,7 +179,6 @@
"HTTP/1.1 200 OK\r\n"
"Content-length: 58\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>200 OK</h1>\nService ready.\n</body></html>\n",
@@ -197,7 +196,6 @@
"HTTP/1.1 401 Unauthorized\r\n"
"Content-length: 112\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>401 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n",
@@ -206,7 +204,6 @@
"HTTP/1.1 403 Forbidden\r\n"
"Content-length: 93\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>403 Forbidden</h1>\nRequest forbidden by administrative rules.\n</body></html>\n",
@@ -215,7 +212,6 @@
"HTTP/1.1 404 Not Found\r\n"
"Content-length: 83\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>404 Not Found</h1>\nThe resource could not be found.\n</body></html>\n",
@@ -224,7 +220,6 @@
"HTTP/1.1 405 Method Not Allowed\r\n"
"Content-length: 146\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>405 Method Not Allowed</h1>\nA request was made of a resource using a request method not supported by that resource\n</body></html>\n",
@@ -233,7 +228,6 @@
"HTTP/1.1 407 Unauthorized\r\n"
"Content-length: 112\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>407 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n",
@@ -251,7 +245,6 @@
"HTTP/1.1 410 Gone\r\n"
"Content-length: 114\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>410 Gone</h1>\nThe resource is no longer available and will not be available again.\n</body></html>\n",
@@ -260,7 +253,6 @@
"HTTP/1.1 421 Misdirected Request\r\n"
"Content-length: 104\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>421 Misdirected Request</h1>\nRequest sent to a non-authoritative server.\n</body></html>\n",
@@ -269,7 +261,6 @@
"HTTP/1.1 425 Too Early\r\n"
"Content-length: 80\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>425 Too Early</h1>\nYour browser sent early data.\n</body></html>\n",
@@ -278,7 +269,6 @@
"HTTP/1.1 429 Too Many Requests\r\n"
"Content-length: 117\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>429 Too Many Requests</h1>\nYou have sent too many requests in a given amount of time.\n</body></html>\n",
@@ -287,7 +277,6 @@
"HTTP/1.1 500 Internal Server Error\r\n"
"Content-length: 96\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>500 Internal Server Error</h1>\nAn internal server error occured.\n</body></html>\n",
@@ -296,7 +285,6 @@
"HTTP/1.1 502 Bad Gateway\r\n"
"Content-length: 107\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>502 Bad Gateway</h1>\nThe server returned an invalid or incomplete response.\n</body></html>\n",
@@ -305,7 +293,6 @@
"HTTP/1.1 503 Service Unavailable\r\n"
"Content-length: 107\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>503 Service Unavailable</h1>\nNo server is available to handle this request.\n</body></html>\n",
@@ -314,11 +301,9 @@
"HTTP/1.1 504 Gateway Time-out\r\n"
"Content-length: 92\r\n"
"Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>504 Gateway Time-out</h1>\nThe server didn't respond in time.\n</body></html>\n",
-
};
const struct ist http_known_methods[HTTP_METH_OTHER] = {