A client that stops sending after the app answers is timed out (closes #130)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
When the app answered before the client had sent its whole body, and its answer ended with its last bytes, every timeout was stopped, SWWAF_CLIENT_REQUEST_TIMEOUT included. The transport went on waiting to read the body, and Go's server cannot send the answer until that read returns, so a client that stopped sending held the request until it closed the connection. The timeouts now run on until the client has sent its body, as they do before the app answers: once SWWAF_CLIENT_REQUEST_TIMEOUT runs out the client is sent the app's answer, the connection is closed, and the log line says timed_out. Model: opus-5-5
This commit is contained in:
@@ -194,6 +194,28 @@ func sendLargeBody(t *testing.T, addr string) net.Conn {
|
||||
return conn
|
||||
}
|
||||
|
||||
func TestClientStopsSendingAfterTheAppHasAnswered(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// The app answers at once without reading the body, as an app does
|
||||
// for a path it does not serve.
|
||||
app := startApp(t, http.NotFound)
|
||||
addr, out := startProxy(t, app.URL, map[string]string{
|
||||
clientRequestTimeout: shortTimeoutSetting,
|
||||
metricsToken: token,
|
||||
})
|
||||
|
||||
start := time.Now()
|
||||
got := readResponse(t, sendPartOfBody(t, addr))
|
||||
wantTimedOut(t, start)
|
||||
|
||||
// The app's answer came before the time ran out, so the client is
|
||||
// sent that answer, not smallwebwaf's 408.
|
||||
wantStatus(t, got, http.StatusNotFound)
|
||||
wantLine(t, out.requestLine(t), http.StatusNotFound, requestlog.ActionTimedOut)
|
||||
wantLimitHits(t, addr, clientRequestTimeout, 1)
|
||||
}
|
||||
|
||||
func TestAppTooSlowToAnswer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user