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.
This commit is contained in:
Jrme Magnin 2018-12-07 09:03:11 +01:00 committed by Willy Tarreau
parent 4468f1cacb
commit 8657742092
2 changed files with 8 additions and 1 deletions

View File

@ -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 tracked key will be looked up into this alternate table instead of the table
currently being tracked. 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 be_id : integer
Returns an integer containing the current backend's id. It can be used in Returns an integer containing the current backend's id. It can be used in
frontends with responses to check which backend processed the request. frontends with responses to check which backend processed the request.

View File

@ -1258,7 +1258,8 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec
static int static int
smp_fetch_fc_http_major(const struct arg *args, struct sample *smp, const char *kw, void *private) 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.type = SMP_T_SINT;
smp->data.u.sint = (conn && strcmp(conn_get_mux_name(conn), "H2") == 0) ? 2 : 1; 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, { 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 }, { "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 }, { "fc_rcvd_proxy", smp_fetch_fc_rcvd_proxy, 0, NULL, SMP_T_BOOL, SMP_USE_L4CLI },
{ /* END */ }, { /* END */ },
}}; }};