mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
MINOR: support for http-response set-timeout
Added set-timeout action for http-response. Adapted reg-tests and documentation.
This commit is contained in:
parent
7629e82c6e
commit
70d2d9aefc
@ -8087,6 +8087,7 @@ http-response <action> <options...> [ { if | unless } <condition> ]
|
|||||||
- set-mark <mark>
|
- set-mark <mark>
|
||||||
- set-nice <nice>
|
- set-nice <nice>
|
||||||
- set-status <status> [reason <str>]
|
- set-status <status> [reason <str>]
|
||||||
|
- set-timeout { client | server | tunnel } { <timeout> | <expr> }
|
||||||
- set-tos <tos>
|
- set-tos <tos>
|
||||||
- set-var(<var-name>[,<cond>...]) <expr>
|
- set-var(<var-name>[,<cond>...]) <expr>
|
||||||
- set-var-fmt(<var-name>[,<cond>...]) <fmt>
|
- set-var-fmt(<var-name>[,<cond>...]) <fmt>
|
||||||
@ -8332,6 +8333,24 @@ http-response set-status <status> [reason <str>]
|
|||||||
# return "503 Slow Down", custom reason
|
# return "503 Slow Down", custom reason
|
||||||
http-response set-status 503 reason "Slow Down".
|
http-response set-status 503 reason "Slow Down".
|
||||||
|
|
||||||
|
http-response set-timeout { client | server | tunnel } { <timeout> | <expr> }
|
||||||
|
[ { if | unless } <condition> ]
|
||||||
|
|
||||||
|
This action overrides the specified "client", "server" or "tunnel" timeout for the
|
||||||
|
current stream only. The timeout can be specified in millisecond or with any
|
||||||
|
other unit if the number is suffixed by the unit as explained at the top of
|
||||||
|
this document. It is also possible to write an expression which must returns
|
||||||
|
a number interpreted as a timeout in millisecond.
|
||||||
|
|
||||||
|
Note that the server/tunnel timeouts are only relevant on the backend side
|
||||||
|
and thus this rule is only available for the proxies with backend
|
||||||
|
capabilities. As well as client timeout is only relevant for frontend side.
|
||||||
|
Also the timeout value must be non-null to obtain the expected results.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
http-response set-timeout tunnel 5s
|
||||||
|
http-response set-timeout server res.hdr(X-Refresh-Seconds),mul(1000)
|
||||||
|
|
||||||
http-response set-tos <tos> [ { if | unless } <condition> ]
|
http-response set-tos <tos> [ { if | unless } <condition> ]
|
||||||
|
|
||||||
This is used to set the TOS or DSCP field value of packets sent to the client
|
This is used to set the TOS or DSCP field value of packets sent to the client
|
||||||
|
@ -4,7 +4,7 @@ feature ignore_unknown_macro
|
|||||||
|
|
||||||
#REQUIRE_VERSION=2.4
|
#REQUIRE_VERSION=2.4
|
||||||
|
|
||||||
server srv_h1 -repeat 5 {
|
server srv_h1 -repeat 9 {
|
||||||
rxreq
|
rxreq
|
||||||
txresp
|
txresp
|
||||||
} -start
|
} -start
|
||||||
@ -34,6 +34,26 @@ syslog Slog5 -level info {
|
|||||||
expect ~ "^.*timeout: 5000 3000.*$"
|
expect ~ "^.*timeout: 5000 3000.*$"
|
||||||
} -start
|
} -start
|
||||||
|
|
||||||
|
syslog Slog6 -level info {
|
||||||
|
recv
|
||||||
|
expect ~ "^.*timeout: 5000 5000.*$"
|
||||||
|
} -start
|
||||||
|
|
||||||
|
syslog Slog7 -level info {
|
||||||
|
recv
|
||||||
|
expect ~ "^.*timeout: 5000 5000.*$"
|
||||||
|
} -start
|
||||||
|
|
||||||
|
syslog Slog8 -level info {
|
||||||
|
recv
|
||||||
|
expect ~ "^.*timeout: 5000 3000.*$"
|
||||||
|
} -start
|
||||||
|
|
||||||
|
syslog Slog9 -level info {
|
||||||
|
recv
|
||||||
|
expect ~ "^.*timeout: 5000 3000.*$"
|
||||||
|
} -start
|
||||||
|
|
||||||
haproxy hap -conf {
|
haproxy hap -conf {
|
||||||
defaults
|
defaults
|
||||||
timeout connect 5s
|
timeout connect 5s
|
||||||
@ -87,6 +107,46 @@ haproxy hap -conf {
|
|||||||
backend be2
|
backend be2
|
||||||
mode http
|
mode http
|
||||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||||
|
|
||||||
|
listen li4
|
||||||
|
mode http
|
||||||
|
bind "fd@${li4}"
|
||||||
|
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||||
|
log ${Slog6_addr}:${Slog6_port} len 2048 local0 debug err
|
||||||
|
http-response set-timeout server 5s
|
||||||
|
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||||
|
|
||||||
|
listen li5
|
||||||
|
mode http
|
||||||
|
bind "fd@${li5}"
|
||||||
|
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||||
|
log ${Slog7_addr}:${Slog7_port} len 2048 local0 debug err
|
||||||
|
http-response set-timeout client 5s
|
||||||
|
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||||
|
|
||||||
|
frontend fe3
|
||||||
|
mode http
|
||||||
|
bind "fd@${fe3}"
|
||||||
|
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||||
|
log ${Slog8_addr}:${Slog8_port} len 2048 local0 debug err
|
||||||
|
default_backend be1
|
||||||
|
|
||||||
|
backend be3
|
||||||
|
mode http
|
||||||
|
http-response set-timeout server int(3),mul(1000)
|
||||||
|
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||||
|
|
||||||
|
frontend fe4
|
||||||
|
mode http
|
||||||
|
bind "fd@${fe4}"
|
||||||
|
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||||
|
log ${Slog9_addr}:${Slog9_port} len 2048 local0 debug err
|
||||||
|
http-response set-timeout client int(3),mul(1000)
|
||||||
|
default_backend be2
|
||||||
|
|
||||||
|
backend be4
|
||||||
|
mode http
|
||||||
|
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||||
} -start
|
} -start
|
||||||
|
|
||||||
client c1 -connect ${hap_li1_sock} {
|
client c1 -connect ${hap_li1_sock} {
|
||||||
@ -119,8 +179,36 @@ client c5 -connect ${hap_fe2_sock} {
|
|||||||
expect resp.status == 200
|
expect resp.status == 200
|
||||||
} -run
|
} -run
|
||||||
|
|
||||||
|
client c6 -connect ${hap_li4_sock} {
|
||||||
|
txreq
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
} -run
|
||||||
|
|
||||||
|
client c7 -connect ${hap_fe3_sock} {
|
||||||
|
txreq
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
} -run
|
||||||
|
|
||||||
|
client c8 -connect ${hap_li5_sock} {
|
||||||
|
txreq
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
} -run
|
||||||
|
|
||||||
|
client c9 -connect ${hap_fe4_sock} {
|
||||||
|
txreq
|
||||||
|
rxresp
|
||||||
|
expect resp.status == 200
|
||||||
|
} -run
|
||||||
|
|
||||||
syslog Slog1 -wait
|
syslog Slog1 -wait
|
||||||
syslog Slog2 -wait
|
syslog Slog2 -wait
|
||||||
syslog Slog3 -wait
|
syslog Slog3 -wait
|
||||||
syslog Slog4 -wait
|
syslog Slog4 -wait
|
||||||
syslog Slog5 -wait
|
syslog Slog5 -wait
|
||||||
|
syslog Slog6 -wait
|
||||||
|
syslog Slog7 -wait
|
||||||
|
syslog Slog8 -wait
|
||||||
|
syslog Slog9 -wait
|
||||||
|
@ -2464,6 +2464,7 @@ static struct action_kw_list http_res_actions = {
|
|||||||
{ "set-status", parse_http_set_status, 0 },
|
{ "set-status", parse_http_set_status, 0 },
|
||||||
{ "strict-mode", parse_http_strict_mode, 0 },
|
{ "strict-mode", parse_http_strict_mode, 0 },
|
||||||
{ "track-sc", parse_http_track_sc, KWF_MATCH_PREFIX },
|
{ "track-sc", parse_http_track_sc, KWF_MATCH_PREFIX },
|
||||||
|
{ "set-timeout", parse_http_set_timeout, 0 },
|
||||||
{ "wait-for-body", parse_http_wait_for_body, 0 },
|
{ "wait-for-body", parse_http_wait_for_body, 0 },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user