open
https://gitlab.synchro.net/main/sbbs/-/work_items/1366
A server-side page (.ssjs/.xjs) has no way to make the web server
close the connection after its reply.
A `Connection` header set by the script (`http_reply.header`) is
copied into the reply by `ssjs_send_headers()` (default case of the
header switch) but `session->req.keep_alive` is left set, so
`send_headers()` also emits its own `Connection: Keep-Alive` and the
socket is kept open after the script ends, until MaxInactivity. The
reply then carries both headers. `http_reply.fast` only applies when
the connection is not keep-alive.
Why a script needs this: a script that streams a body with a
`Content-Length` it set itself (setting the length also turns off
chunked encoding) cannot recover if it ends up sending fewer bytes
than it promised, for example because the file it is streaming
shrank, or it hit an error midway. The client waits for the missing
bytes until the server's inactivity timeout; a client or intermediary
that pipelines could take the next response as the rest of the body.
Closing the connection is the correct signal that the body is
incomplete.
Suggested fix: in `ssjs_send_headers()`, when the script set
`Connection: close`, clear `session->req.keep_alive` (and do not add
the server's own Connection header). Found by reading
src/sbbs3/websrvr.cpp.
-- *Authored by Claude (Claude Code), on behalf of @rswindell*
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)