From: Jérôme Magnin Date: Fri, 7 Dec 2018 08:03:11 +0000 (+0100) Subject: MINOR: sample: add bc_http_major X-Git-Tag: v1.9-dev10~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8657742092df3c5dbaab8b88ab8907644890fb07;p=thirdparty%2Fhaproxy.git MINOR: sample: add bc_http_major This adds the sample fetch bc_http_major. It returns the backend connection's HTTP version encoding, which may be 1 for HTTP/0.9 to HTTP/1.1 or 2 for HTTP/2.0. It is based on the on-wire encoding, and not the version present in the request header. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index e6678c17c5..2d7fb68879 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -14352,6 +14352,11 @@ table may be specified with the "sc*" form, in which case the currently tracked key will be looked up into this alternate table instead of the table currently being tracked. +bc_http_major: integer + Returns the backend connection's HTTP major version encoding, which may be 1 + for HTTP/0.9 to HTTP/1.1 or 2 for HTTP/2. Note, this is based on the on-wire + encoding and not the version present in the request header. + be_id : integer Returns an integer containing the current backend's id. It can be used in frontends with responses to check which backend processed the request. diff --git a/src/connection.c b/src/connection.c index 054e1998fd..2b0063e6a9 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1258,7 +1258,8 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec static int smp_fetch_fc_http_major(const struct arg *args, struct sample *smp, const char *kw, void *private) { - struct connection *conn = objt_conn(smp->sess->origin); + struct connection *conn = (kw[0] != 'b') ? objt_conn(smp->sess->origin) : + smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL; smp->data.type = SMP_T_SINT; smp->data.u.sint = (conn && strcmp(conn_get_mux_name(conn), "H2") == 0) ? 2 : 1; @@ -1293,6 +1294,7 @@ int smp_fetch_fc_rcvd_proxy(const struct arg *args, struct sample *smp, const ch */ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { "fc_http_major", smp_fetch_fc_http_major, 0, NULL, SMP_T_SINT, SMP_USE_L4CLI }, + { "bc_http_major", smp_fetch_fc_http_major, 0, NULL, SMP_T_SINT, SMP_USE_L4SRV }, { "fc_rcvd_proxy", smp_fetch_fc_rcvd_proxy, 0, NULL, SMP_T_BOOL, SMP_USE_L4CLI }, { /* END */ }, }};