Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return HTTP response to RX_OVERFLOW #4207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/varnishd/http1/cache_http1_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ HTTP1_Session(struct worker *wrk, struct req *req)
cache_param->http_req_size);
assert(!WS_IsReserved(req->htc->ws));
if (hs < HTC_S_EMPTY) {
if (FEATURE(FEATURE_OVERFLOW_HTTP_RESP) && hs == HTC_S_OVERFLOW) {
(void)req->transport->minimal_response(req,
cache_param->req_overflow_status);
}
req->acct.req_hdrbytes +=
req->htc->rxbuf_e - req->htc->rxbuf_b;
Req_AcctLogCharge(wrk->stats, req);
Expand Down
28 changes: 28 additions & 0 deletions bin/varnishtest/tests/b00092.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
varnishtest "HTTP response to RX_OVERFLOW"

# server s1 {} -start

varnish v1 -cliok "param.set http_req_size 500b" -vcl {
backend default none;
} -start

client c1 {
txreq -url "/world?hello=world${string,repeat,100,&hello=world}"
expect_close
} -run

varnish v1 -cliok "param.set feature +overflow_http_resp"

client c1 {
txreq -url "/world?hello=world${string,repeat,100,&hello=world}"
rxresp
expect resp.status == 413
} -run

varnish v1 -cliok "param.set req_overflow_status 414"

client c1 {
txreq -url "/world?hello=world${string,repeat,100,_hello-world}"
rxresp
expect resp.status == 414
} -run
4 changes: 4 additions & 0 deletions include/tbl/feature_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ FEATURE_BIT(VCL_REQ_RESET, vcl_req_reset,
"When this happens MAIN.req_reset is incremented."
)

FEATURE_BIT(OVERFLOW_HTTP_RESP, overflow_http_resp,
"Send an HTTP response instead of silently closing the socket"
"in case of RX_OVERFLOW.")

#undef FEATURE_BIT

/*lint -restore */
11 changes: 11 additions & 0 deletions include/tbl/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,17 @@ PARAM_SIMPLE(
"IPv4 and IPv6 addresses."
)

PARAM_SIMPLE(
/* name */ req_overflow_status,
/* type */ uint,
/* min */ "400",
/* max */ "499",
/* def */ "413",
/* units */ "HTTP code",
/* descr */
"HTTP code to be returned in case of a request overflow."
)

PARAM_SIMPLE(
/* name */ rush_exponent,
/* type */ uint,
Expand Down