- Added
app.getConnectorStatistics() — live HTTP-layer metrics straight
from Undertow's own listener (active connections/requests, total request
count, bytes sent/received, error count, processing time), for a
server-monitoring dashboard or similar that needs numbers
java.lang.management's JVM/OS MXBeans can't see. listen() now turns
on UndertowOptions.ENABLE_STATISTICS unconditionally (off by default in
Undertow itself, but the per-request tracking overhead is negligible next
to everything else already happening per request here) — without it,
getConnectorStatistics() would just return null always instead of
real numbers. See BoxExpress.bx.
GitHub ↗
About boxlang-express
- Breaking: BoxExpress's server transport is now
Undertow exclusively, replacing the JDK-bundled
com.sun.net.httpserver.HttpServer it ran on before. Verified at full
behavioral parity against the previous JDK-backed server before the
switch (the entire test suite passed running for real against either),
and load-tested with no meaningful throughput/latency difference on the
routes tested. The pluggable HttpServerAdapter seam this module briefly
carried while both engines existed (an injectable adapter via
new BoxExpress(customAdapter), plus a server.engine setting) has been
removed now that Undertow is the only engine — listen()/close() in
models/BoxExpress.bx talk to Undertow directly. models/adapters/
still holds the Undertow-specific wiring classes (exchange wrapping,
handler glue, the virtual-thread dispatcher), just not as a swappable
interface.
GitHub ↗
About boxlang-express
- Fix:
Router.bx reconstructs req.path for app.use()-mounted
middleware/sub-routers from segments produced by splitting on /,
which drops empty segments — so a trailing slash on the incoming path
left no trace once rejoined. Since nearly every request passes through
at least one app.use() layer (even one mounted at root /), this
silently stripped trailing slashes from req.path everywhere
downstream, breaking anything that distinguishes /foo/ from /foo —
notably boxExpressStatic()'s directory-index resolution (/foo/ →
/foo/index.html). Now reattached from the pre-mutation path string,
the only place that still has it by the time the remainder is computed.
See Router.bx.
Full notes
- Static file serving now mirrors
express.static(): a request for a
directory without the trailing slash (/games/void-harvest) redirects
(301) to the slash-suffixed URL instead of 404ing — the slash version
is the canonical one, since relative asset links inside the served HTML
only resolve correctly against it. The redirect target is built from
req.originalUrl rather than req.path, since this middleware commonly
runs after a mount prefix has already been stripped from req.path by
Router.bx, but originalUrl is captured once at request construction
and never mutated by that stripping. See
StaticFiles.bx.
GitHub ↗
About boxlang-express
- Added
resave/saveUninitialized options to boxExpressSession(),
mirroring express-session's own
options of the same name. By default this middleware writes to the
store on every request, even one that never reads or touches
req.session — free against the default in-memory store, a real cost
against anything out-of-process. saveUninitialized: false skips both
the store write and the Set-Cookie for a new session that was never
modified; resave: false skips the store write (cookie still refreshed)
for an existing session that wasn't modified. A session that is
modified is always saved regardless of either option. Both default to
true (the historical behavior), so this doesn't change anything for
existing consumers unless they opt in. See
Session.bx.
- Added
Response.onBeforeSend(callback) — registers a callback that runs
once, synchronously, the instant before headers are actually flushed.
Needed to implement saveUninitialized correctly: whether to send a
session cookie can depend on what next() did to req.session, but by
the time next() returns to a middleware's own frame, a terminal
handler further down the chain has normally already called _end() and
flushed the headers — too late to add one there. The same technique
express-session uses via monkey-patching res.end, done explicitly
here since BoxLang can't intercept it that way. See
Response.bx.
GitHub ↗
About boxlang-express
- Added
Response.getStatusCode()/getBytesWritten() accessors — expose
the eventual status code and body byte count from outside the class,
for request-logging middleware (registered first via app.use()) that
otherwise can't observe a request's outcome. getBytesWritten() is 0
for a response still in flight; both reflect the real outcome even when
a route never called status() directly, since every terminal method
that isn't a plain 200 (redirect(), sendStatus(),
sendFileRange()'s 206/304/416) routes through it internally.
See Response.bx.
GitHub ↗
About boxlang-express
- Fix:
boxExpressSession() persisted req.session to the store
before next() ran, not after — so anything the request chain
mutated on it (boxExpressCsrf() minting a token, a login handler
setting the user, etc.) was written to local memory only and never made
it back to the store. Invisible against the default in-memory
MemoryStore, since structs are pass-by-reference — that early
store.set() call was really just inserting a reference into a
ConcurrentHashMap, and any later mutation of the same object was
automatically visible through it. A real out-of-process store has to
serialize on write (a boxExpressCacheStore()-backed JDBCStore,
Redis, etc.), which breaks that accidental reference-sharing and
exposes the bug for real: a CSRF token minted mid-request never gets
saved, so the very next request — even the form submission that
follows the page that minted it — reads back a session with no token
and 403s. Now persists after next(), wrapped in try/finally so
a throw partway through the chain still saves whatever req.session
held at that point; req.destroySession() skips that save so a
destroyed session isn't silently resurrected by it. See
Session.bx.
GitHub ↗
About boxlang-express
- Added
app.set("trust proxy header", "DO-Connecting-IP") (or an ordered
array of candidates) for platforms where X-Forwarded-For isn't safe to
trust even with trust proxy on — confirmed directly against
DigitalOcean App Platform (with Cloudflare in front of that) that both
hops append to X-Forwarded-For rather than replacing it, so a client
can prepend a forged entry and have it survive to the app, making
req.ip attacker-controlled rather than just wrong. Platforms that do
this typically also inject their own edge-set header carrying the real
client IP (DO-Connecting-IP, CF-Connecting-IP, Fastly-Client-IP,
etc.), set from the connection the edge itself observed rather than
anything the client sent — checked before X-Forwarded-For, and
independent of the trust proxy boolean, since it's a different, safer
trust model. See Request.bx.
- Switched
AnsiColor.bx's NO_COLOR check from
createObject("java","java.lang.System").getenv(...) to the native
getSystemSetting(name, defaultValue) BIF — confirmed directly that it
reads real environment variables (not just JVM system properties) and
never throws when a default is given, so the Java interop wasn't
needed. No behavior change, verified live (NO_COLOR still disables
coloring, a normal run still shows real ANSI codes).
GitHub ↗
About boxlang-express
- Fix:
req.query/req.cookies threw a 500 on a completely ordinary
input — a query param or cookie with an empty key or value (?q=,
?=cats, Cookie: name=, Cookie: =value). Request.bx sliced the
string with left()/right() using a count that could legitimately be
0, which BoxLang throws on ("Count cannot be zero") — the exact bug
class BodyParsers.bx already guarded against, just never applied here.
Along the way, found and fixed a second issue this surfaced: a failure
constructing Request/Response was caught silently in
HttpBridge.bx — no server-side log line, and the
real error message was hidden from the response even with
app.set("env", "development") on, unlike every other error path in the
framework. It now logs and honors env the same way route/middleware
errors already do.
- Fix: a
Range request header of exactly bytes= (a valid header,
just an empty spec) also threw a 500 — same left()/right()
zero-count bug, this time in RangeParser.bx,
whose own dash-split logic already used mid() specifically to avoid
it. Now falls back to a full 200 response, same as any other
unparseable Range header.
- Fix: a sweep of the rest of the codebase for the same
left()/right() zero-count bug turned up six more, all in
Multipart.bx — the most reachable one
being a plain HTML file input submitted with nothing selected
(filename=""), which crashed the whole upload instead of the field
simply being empty, same as it already was for a text field. Also fixed:
an empty boundary= in Content-Type, a multipart part with no headers
or an empty body (a genuinely empty file/field), and a part header with
an empty name or value. All converted to mid(), same fix shape as
RangeParser.bx above.
- Fix: a bare
: path segment (app.get("/:", ...)) — a typo for
:name — threw the same left()/right() zero-count error, but at
route registration time rather than per-request, so it's a developer
papercut rather than anything reachable by a client. Fixed the same way,
but also given a proper BoxExpress.InvalidRoutePath message (matching
every sibling validation in Router.bx) instead of
leaking a raw "Count cannot be zero." engine error with no indication
of what was actually wrong.
- Fix:
listen() created its underlying HttpServer with a TCP accept
backlog of 0 (the JDK default), which turned out to be a real capacity
ceiling — confirmed with a live load test (ab): request handling itself
stayed fast and error-free throughout, but new connections started getting
refused with a reset once concurrency passed roughly 65-70 in repeated
runs. listen(port, callback, { backlog: n }) now defaults to 1024,
which pushed the same test past 150 with no other change. See
BoxExpress.bx.
GitHub ↗
About boxlang-express
- Fix + feature:
app.get(path, ...) routes now automatically answer
HEAD too — same handler and headers (including Content-Length), body
discarded, same as Express — instead of 404ing. This also fixes a real bug
in static file serving: it already accepted HEAD requests, but sent the
full file body anyway, a spec violation for a HEAD response. Register
app.head(path, ...) explicitly (before the matching app.get()) only
when HEAD should behave differently than discarding the GET body.
Full notes
- Fix:
app.use()/router.use() only ever accepted a single handler
(or a single path + single handler), unlike route registration
(app.get(path, mw1, mw2, handler)), which already took a variadic
chain. Calling app.use(mw1, mw2, mw3) — a common Express pattern —
didn't just silently drop the extra arguments, it threw a confusing
low-level error (the second handler got mistaken for a mount path).
use() now accepts any number of handlers (and/or a Router) in one
call, at the same mount point, registered in order. See
Router.bx.
- Added
boxExpressHelmet() — security-headers middleware mirroring the
npm helmet package's most
commonly used defaults (X-Frame-Options, X-Content-Type-Options,
Referrer-Policy, etc.), each individually overridable or disable-able.
Strict-Transport-Security and Content-Security-Policy are opt-in
rather than on by default. See Helmet.bx.
- Added
boxExpressCors() — Cross-Origin Resource Sharing middleware
mirroring the npm cors package's
common options (origin, methods, allowedHeaders, credentials,
maxAge). Answers a CORS preflight OPTIONS request directly, since
nothing would otherwise be registered to handle it. See
Cors.bx.
- Added
boxExpressRateLimit() — fixed-window rate limiting mirroring the
npm express-rate-limit
package's common options (windowMs, max, keyGenerator), keyed by
req.ip by default. Sets the draft-standard RateLimit-* headers and
responds 429 with Retry-After once a key's count exceeds max. See
RateLimit.bx.
- Added
boxExpressCsrf() — CSRF protection mirroring the classic
csurf package's session-based
token strategy. Requires req.session (register after
boxExpressSession(), which it throws immediately about if missing);
exposes req.csrfToken(), validates req.body._csrf (or a request
header) on every method other than GET/HEAD/OPTIONS. See
Csrf.bx.
boxExpressStatic()/res.sendFile() now accept options.maxAge
(seconds) to set Cache-Control: public, max-age=<n> alongside the
ETag/Last-Modified they already set — off by default, no header at
all unless asked for.
- Added
boxExpressCacheStore() — a Session store backed by BoxLang's
own cache() service, so { store: boxExpressCacheStore( "sessions" ) }
makes sessions durable across restarts and shared across a cluster when
the named cache is configured with objectStore: "JDBCStore" (a real SQL
table) instead of the in-memory default. See
CacheStore.bx.
GitHub ↗
About boxlang-express
- Added
Range request support (RFC 7233) to res.sendFile()/download()
and static file serving — a request naming a byte range now gets a 206 Partial Content response with just that slice instead of the whole file,
enabling video/audio scrubbing and resumable downloads. Every file
response now sets Accept-Ranges: bytes. Multi-range requests and
If-Range aren't supported — see RangeParser.bx.
- Added
app.locals/res.locals — two plain structs merged into every
res.render() call's data (app.locals < res.locals < the explicit
data argument, each overriding the last), so values a route doesn't set
explicitly don't have to be threaded through every render() call by hand.
Full notes
- Added
req.protocol, req.secure, and req.hostname — same trust proxy trust model as req.ip (X-Forwarded-Proto/X-Forwarded-Host
are only honored when app.set("trust proxy", true)), since BoxExpress's
own HttpServer never terminates TLS itself.
- Added optional trailing route params (
/users/:id?) — same restriction
as the * wildcard, only supported as the final path segment, since
matching one anywhere else would need real backtracking. See
Router.bx.
GitHub ↗
About boxlang-express
- Fix:
reloadOnChange could silently kill the server on a failed
restart. _restartProcess() called close() unconditionally before
attempting to launch the replacement process — if that launch failed for
any reason (a transient OS resource limit, a bad reconstructed command,
etc.), the exception was uncaught on the watcher's daemon thread, and by
then the old server was already torn down with nothing left running and
no clear error tying the two together. Launching the replacement is now
attempted before close() releases the port; a failed launch is caught,
logged in red, and the current server is left running instead of dying
with it. See BoxExpress.bx.
GitHub ↗
About boxlang-express
- Added graceful process shutdown:
listen() now registers a JVM shutdown
hook so Ctrl-C/SIGTERM/normal exit runs close() (stopping the
httpServer and, if running, the reloadOnChange watcher) instead of
getting torn down mid-flight — previously the watcher's daemon thread
could outlive a killed server. close() is now idempotent, and a bad
port bind is caught and reported with a friendly message plus exit(1)
instead of a raw stack trace.
- Added
res.dump(data) — sends BoxLang's HTML dump() view of a variable
as the response, round-tripped through a temp file since
dump(format="html") only ever writes to the process console under
BoxExpress's CLI-based HttpServer.
Full notes
- Added colored console output (
AnsiColor.bx): the access log gets a gray
timestamp, a method colored by verb (GET=cyan, POST=green,
PUT/PATCH=yellow, DELETE=red, everything else=magenta), and a dim
IP; the reloadOnChange restart notice is cyan; fatal/error lines are
red. Respects NO_COLOR — set it to get plain
text, e.g. when piping stdout to a file or log aggregator.
- Broadened test coverage:
PUT/PATCH/DELETE/all() routing,
res.header()/type()/end()/sendBytes(), req.get()/
rawExchange()/ip() (including the trust proxy X-Forwarded-For
case), app.param(), res.redirect() with an explicit status, and
close() idempotency — plus a new ProcessLifecycleSpec.bx covering
behavior that needs a real OS process boundary (port-conflict exit code,
SIGTERM releasing the socket, reloadOnChange actually replacing the
process). The test suite's HttpClient.bx helper moved from
HttpURLConnection to java.net.http.HttpClient, since the former
hard-rejects PATCH.
GitHub ↗
About boxlang-express
- Fix: the router's dispatch loop sometimes called
next()/_final()
with an explicit null error argument on the success path, instead of
calling them with no argument at all. Express's own contract distinguishes
the two — next() (no args) means "move on successfully," next(err)
means "jump to error handling" — and code downstream that cared about the
distinction (rather than just checking isNull(err)) could misread a
null-argument call as an error. next()/_final() are now called
argument-free whenever there's no error, matching Express. See
Router.bx.
GitHub ↗
About boxlang-express
- Added
app.set("reloadOnChange", true) — watches the working directory
for .bx/.bxs/.bxm changes and restarts the process on save, using
java.nio.file.WatchService and ProcessHandle.current() to replay the
original launch command. See FileWatcher.bx.
GitHub ↗
About boxlang-express
- Fix:
boxExpressStatic() threw on any request to the mount root
(/) instead of falling through to next(), returning a generic 500
for what should have been the app's own route handler. The middleware
stripped the leading slash with req.path.right( req.path.len() - 1 ),
which becomes right(0) for req.path == "/" — BoxLang's right()
throws "Count cannot be zero" for a zero count (CF/Lucee just returns
""). Switched to mid(), which handles it correctly.
GitHub ↗
About boxlang-express
- Added
app.param(name, callback) (Express-style route-param preprocessing),
app.route(path) (chainable per-path route builder), and conditional GET
support (ETag/Last-Modified/304) for res.sendFile() and static file
serving.
GitHub ↗
About boxlang-express
- Security fix: the default
500 error handler echoed the raw exception
message straight back to unauthenticated clients — this could leak
internal details (absolute server file paths, driver errors, etc.) on any
unhandled error, reachable via nothing more than a malformed body sent to
the opt-in JSON parser. The default now sends a generic
"Internal Server Error" message; the real message is still logged to
stdout, and still returned in the response if the app opts in with
app.set("env", "development").
GitHub ↗
About boxlang-express
- Security fix:
res.sendFile()/res.download() interpolated a
caller-supplied filename into the Content-Disposition header
unescaped, letting an attacker-controlled value (e.g. passed straight
through from a query param) break out of the quoted filename="..."
token and inject extra header parameters. Quote and control characters
are now stripped before the value reaches the header.
- Added file upload (
boxExpressUpload() / Multipart middleware,
req.files) and download (res.sendFile(), res.download()) support.
GitHub ↗
About boxlang-express
listen() now blocks the calling thread by default (options.block),
matching Node's effective behavior — no more manual keep-alive loop
required in consuming apps.
- Added request logging: every request gets a line on stdout as soon as
it's received.
GitHub ↗
About boxlang-express
- Added Handlebars (
.hbs) view rendering alongside the native .bxm
engine.
GitHub ↗
About boxlang-express