mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
OPTIM: lua: don't add "Connection: close" on the response
Haproxy doesn't need this anymore, we're wasting cycles checking for a Connection header in order to add "Connection: close" only in the 1.1 case so that haproxy sees it and removes it. All tests were run in 1.0 and 1.1, with/without the request header, and in the various keep-alive/close modes, with/without compression, and everything works fine. It's worth noting that this header was inherited from the stats applet and that the same cleanup probably ought to be done there as well.
This commit is contained in:
parent
a329463655
commit
ee1bdd5a03
17
src/hlua.c
17
src/hlua.c
@ -4200,7 +4200,6 @@ __LJMP static int hlua_applet_http_start_response(lua_State *L)
|
|||||||
const char *value;
|
const char *value;
|
||||||
size_t value_len;
|
size_t value_len;
|
||||||
int id;
|
int id;
|
||||||
int hdr_connection = 0;
|
|
||||||
long long hdr_contentlength = -1;
|
long long hdr_contentlength = -1;
|
||||||
int hdr_chunked = 0;
|
int hdr_chunked = 0;
|
||||||
const char *reason = appctx->appctx->ctx.hlua_apphttp.reason;
|
const char *reason = appctx->appctx->ctx.hlua_apphttp.reason;
|
||||||
@ -4283,10 +4282,6 @@ __LJMP static int hlua_applet_http_start_response(lua_State *L)
|
|||||||
|
|
||||||
/* Protocol checks. */
|
/* Protocol checks. */
|
||||||
|
|
||||||
/* Check if the header conneciton is present. */
|
|
||||||
if (name_len == 10 && strcasecmp("connection", name) == 0)
|
|
||||||
hdr_connection = 1;
|
|
||||||
|
|
||||||
/* Copy the header content length. The length conversion
|
/* Copy the header content length. The length conversion
|
||||||
* is done without control. If it contains a bad value,
|
* is done without control. If it contains a bad value,
|
||||||
* the content-length remains negative so that we can
|
* the content-length remains negative so that we can
|
||||||
@ -4309,18 +4304,6 @@ __LJMP static int hlua_applet_http_start_response(lua_State *L)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the http protocol version is 1.1, we expect an header "connection" set
|
|
||||||
* to "close" to be HAProxy/keeplive compliant. Otherwise, we expect nothing.
|
|
||||||
* If the header conneciton is present, don't change it, if it is not present,
|
|
||||||
* we must set.
|
|
||||||
*
|
|
||||||
* we set a "connection: close" header for ensuring that the keepalive will be
|
|
||||||
* respected by haproxy. HAProcy considers that the application cloe the connection
|
|
||||||
* and it keep the connection from the client open.
|
|
||||||
*/
|
|
||||||
if (appctx->appctx->ctx.hlua_apphttp.flags & APPLET_HTTP11 && !hdr_connection)
|
|
||||||
chunk_appendf(tmp, "Connection: close\r\n");
|
|
||||||
|
|
||||||
/* If we dont have a content-length set, and the HTTP version is 1.1
|
/* If we dont have a content-length set, and the HTTP version is 1.1
|
||||||
* and the status code implies the presence of a message body, we must
|
* and the status code implies the presence of a message body, we must
|
||||||
* announce a transfer encoding chunked. This is required by haproxy
|
* announce a transfer encoding chunked. This is required by haproxy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user