Compare commits

1 Commits
Author SHA1 Message Date
sneak baa90d7625 README and SPEC say when a client too slow to send its request line or headers is answered 400 (closes #138)
check / check (push) Canceled after 0s
When SWWAF_CLIENT_REQUEST_TIMEOUT runs out partway through a line, Go's
server reads the part that arrived, a carriage return without its line
feed included, as the whole line. If that part cannot be read as a line,
it answers 400; otherwise it closes the connection without an answer.
The README's "Request log" and SPEC's size and time limits said such a
client always gets no answer, and both documents' summaries of answers
gave 408 for any slow client, when it is only for a slow body.

Model: opus-5-5
2026-10-20 11:33:51 +00:00
2 changed files with 26 additions and 16 deletions
+13 -8
View File
@@ -112,11 +112,11 @@ in `bin/state` unless `SWWAF_STATE_DIR` is set, and the default rule file of
log line (see `request_id` in "Request log" below). log line (see `request_id` in "Request log" below).
- Enforces the timeouts and the size limits below. A limit passed before the - Enforces the timeouts and the size limits below. A limit passed before the
response has started gets `smallwebwaf`'s own answer: `408` for a client too response has started gets `smallwebwaf`'s own answer: `408` for a client too
slow to send its request, `413` for a request body that is too large, `504` slow to send its body, `413` for a request body that is too large, `504` for
for an app too slow to answer, and `502` for a response that is too large or an app too slow to answer, and `502` for a response that is too large or an
an app that cannot be reached. A request that announces a body over the limit app that cannot be reached. A request that announces a body over the limit is
is refused before anything reaches the app. While a request body is still on refused before anything reaches the app. While a request body is still on its
its way, a request timeout that runs out answers `408` if `smallwebwaf` was way, a request timeout that runs out answers `408` if `smallwebwaf` was
waiting for the client to send more, and `504` if it was waiting for the app waiting for the client to send more, and `504` if it was waiting for the app
to take what it had. Once the response has started, a limit can only cut the to take what it had. Once the response has started, a limit can only cut the
connection. connection.
@@ -1042,9 +1042,14 @@ less severe than `SWWAF_LOG_LEVEL` are not written.
Go's HTTP server, on which `smallwebwaf` is built, reads a request's line and Go's HTTP server, on which `smallwebwaf` is built, reads a request's line and
headers before `smallwebwaf` sees the request, and some requests end there, headers before `smallwebwaf` sees the request, and some requests end there,
without a line in the log: headers over `SWWAF_CLIENT_REQUEST_HEADER_MAX_BYTES`, without a line in the log: headers over `SWWAF_CLIENT_REQUEST_HEADER_MAX_BYTES`,
which it answers `431`, headers slower than `SWWAF_CLIENT_REQUEST_TIMEOUT`, which it answers `431`, requests it cannot read at all, which it answers itself,
whose connection it closes without an answer, and requests it cannot read at mostly with `400`, and a request line and headers slower than
all, which it answers itself, mostly with `400`. `SWWAF_CLIENT_REQUEST_TIMEOUT`. When that time runs out, the server takes what
has arrived of the line it is reading for the whole line, and answers `400` if
that is not a line it can read, as for a request line cut before the end of its
HTTP version, a header cut before its colon, or a line cut between its carriage
return and line feed. Otherwise, as for a client that stops right after a line
feed, it closes the connection without an answer.
### Sending the log to a syslog server ### Sending the log to a syslog server
+13 -8
View File
@@ -437,10 +437,10 @@ The settings, by group:
the app sends it and the client receives it. the app sends it and the client receives it.
- When a limit is passed before the response has started, `smallwebwaf` - When a limit is passed before the response has started, `smallwebwaf`
answers itself: `413` for a request body that is too large, `408` for a answers itself: `413` for a request body that is too large, `408` for a
client that is too slow, `502` for a response that is too large, `504` for client too slow to send its body, `502` for a response that is too large,
an app that is too slow. A request that announces a body larger than its `504` for an app that is too slow. A request that announces a body larger
limit is refused before anything reaches the app. Once the response has than its limit is refused before anything reaches the app. Once the
started it can only be cut off, and the connection is closed. response has started it can only be cut off, and the connection is closed.
- Since a request body streams through, each side can hold up the other: a - Since a request body streams through, each side can hold up the other: a
slow client slows the send to the app, and an app slow to take the body slow client slows the send to the app, and an app slow to take the body
slows the client's send. So while a request body is still on its way, a slows the client's send. So while a request body is still on its way, a
@@ -449,11 +449,16 @@ The settings, by group:
waiting for the client to send more at that moment, and `504` if it was waiting for the client to send more at that moment, and `504` if it was
waiting for the app to take what it had. waiting for the app to take what it had.
- Go's HTTP server, on which `smallwebwaf` is built, reads a request's line - Go's HTTP server, on which `smallwebwaf` is built, reads a request's line
and headers before `smallwebwaf` sees the request. A client that takes and headers before `smallwebwaf` sees the request. When
longer than `SWWAF_CLIENT_REQUEST_TIMEOUT` to send them gets no answer: `SWWAF_CLIENT_REQUEST_TIMEOUT` runs out before they have all arrived, the
the server closes its connection. Headers over server takes what has arrived of the line it is reading for the whole
line, and answers `400` if that is not a line it can read, as for a
request line cut before the end of its HTTP version, a header cut before
its colon, or a line cut between its carriage return and line feed.
Otherwise, as for a client that stops right after a line feed, it closes
the connection without an answer. Headers over
`SWWAF_CLIENT_REQUEST_HEADER_MAX_BYTES` are answered `431` by the server `SWWAF_CLIENT_REQUEST_HEADER_MAX_BYTES` are answered `431` by the server
itself. Neither request gets a line in the request log. itself. None of these requests gets a line in the request log.
- A WebSocket connection leaves these limits behind once it is upgraded: it - A WebSocket connection leaves these limits behind once it is upgraded: it
stays open until either side closes it. stays open until either side closes it.
- Lookup of AS number and country (R7). On by default through GeoJS, which needs - Lookup of AS number and country (R7). On by default through GeoJS, which needs