Mailing List Archive

[6.0] 83881e9f0 req_fsm: Use status 408 for reset streams
commit 83881e9f0e897603ab7eb3aea1fd0f5a4a7f7a5c
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Fri Dec 1 16:25:00 2023 +0100

req_fsm: Use status 408 for reset streams

The 503 synth and 500 minimal response status codes are too misleading
in this context, where the failure is attributed to the client. Among
existing 4XX status codes, this is the closest if we stretch the timeout
definition to "didn't complete rapidly enough before the client went
away".

Conflicts:
bin/varnishd/cache/cache_req_fsm.c

There is no minimal 500 response on this branch.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 43d3e6d68..c71c5e67f 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -275,8 +275,13 @@ cnt_vclfail(const struct worker *wrk, struct req *req)

Req_Rollback(req);

- req->err_code = 503;
- req->err_reason = "VCL failed";
+ if (req->req_reset) {
+ req->err_code = 408;
+ req->err_reason = "Client disconnected";
+ } else {
+ req->err_code = 503;
+ req->err_reason = "VCL failed";
+ }
req->req_step = R_STP_SYNTH;
req->doclose = SC_VCL_FAILURE;
return (REQ_FSM_MORE);
diff --git a/bin/varnishtest/tests/t02025.vtc b/bin/varnishtest/tests/t02025.vtc
index 578dbf5c8..4b83fe95b 100644
--- a/bin/varnishtest/tests/t02025.vtc
+++ b/bin/varnishtest/tests/t02025.vtc
@@ -46,7 +46,7 @@ varnish v1 -expect req_reset == 1
# is interpreted as before a second elapsed. Session VXIDs showing up
# numerous times become increasingly more suspicious. The format can of
# course be extended to add anything else useful for data mining.
-shell -expect "1000 ${localhost}" {
+shell -expect "1000 ${localhost} 408" {
varnishncsa -n ${v1_name} -d \
- -q 'Timestamp:Reset[2] < 1.0' -F '%{VSL:Begin[2]}x %h'
+ -q 'Timestamp:Reset[2] < 1.0' -F '%{VSL:Begin[2]}x %h %s'
}
diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst
index b52956226..83ffc36e2 100644
--- a/doc/sphinx/reference/vsl.rst
+++ b/doc/sphinx/reference/vsl.rst
@@ -74,7 +74,8 @@ Restart
Reset
The client closed its connection, reset its stream or caused
a stream error that forced Varnish to reset the stream. Request
- processing is interrupted and considered failed.
+ processing is interrupted and considered failed, with a 408
+ "Request Timeout" status code.

Pipe handling timestamps
~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit