Skip to content

Sherver 1.1

Latest

Choose a tag to compare

@remileduc remileduc released this 18 Oct 16:41
· 5 commits to master since this release
v1.1
9df2b4f

Sherver speaks HTTP/1.1 now, and behaves like it: the request line and the Host header are
validated, OPTIONS is answered, and a file can be served by byte range — which is what makes
<video> seeking work. Nothing was removed from the scripting API.

  • answers in HTTP/1.1, to a 1.0 client as well (RFC 9112 §2.3)
  • REQUEST_HTTP_VERSION is validated instead of merely parsed: anything that is not HTTP/1.x is a
    400, another major version a 505
  • Host is mandatory on an HTTP/1.1 request, missing it is a 400. OK for HTTP/1.0 request
  • header lines are validated: sends 400 for bad requests (RFC 9112 §5, §5.1, §5.2, §3.2 and
    §6.3, RFC 9110 §5.5).
  • Repeated header reaches REQUEST_HEADERS as the v1, v2 list it stands for (RFC 9110 §5.2)
    except Cookie, whose pairs recombine on ; (RFC 9113 §8.2.3)
  • byte ranges: advertise Accept-Ranges: bytes, and GET carrying a single Range: bytes=…
    gets a 206 with its Content-Range. A range we can't use falls back to the full 200;
    only one that selects nothing — starting at or past the end — is a 416
  • OPTIONS, answered by the dispatcher for any target, * included, with Allow and an empty
    body. PUT, DELETE, PATCH, TRACE and CONNECT still get a 405.
    Do the same before your own send_error 405.
  • absolute-form request target: GET http://host/path HTTP/1.1 is accepted, as RFC 9112 §3.2.2
  • an error is never stored: send_error answers Cache-Control: no-store and drops any ETag and
    Last-Modified already set
  • no more Expires: Cache-Control is the only freshness field now.
  • a chunked request body is a 411, where it was silently read as no body at all: chunked
    framing is still not decoded, but it is refused loudly, on any method.
  • Expect: 100-continue is answered (RFC 9110 §10.1.1) with HTTP/1.1 100 Continue
  • an Expect naming anything but 100-continue is a 417 Expectation Failed
  • a request has 10 s to arrive whole, body included, or it is a 408 Request Timeout: socat -T
    only ever dropped a client gone silent, and one dripping a byte every 9 s held a dispatcher for
    hours. MAX_REQUEST_TIME is the knob, next to MAX_BODY_SIZE and MAX_HEADERS_SIZE
  • HTTP_RESPONSE gains the codes that go with all this:
    100, 206, 301, 302, 303, 307, 308, 408, 411, 416, 417, 501, 505
  • tail and head join the external commands, for range answers only — busybox's are enough
  • add support for redirections 30X
  • add support for Last-Modified header
  • add IP in logs
  • command line flags replace editing sherver.sh: --port N, --ipv4, --tls,
    --certs DIR, --debug, --version, and --help
  • bash 4.4 is the floor, checked at startup by sherver.sh, dispatcher.sh and
    tests/lint.sh

Deliberately left out, and worth knowing about:

  • no keep alive, and none planned: Connection: close on every response is a compliant opt-out
    (RFC 9112 §9.6), and one process per connection is the whole architecture
  • a chunked request body is refused with a 411 rather than decoded. No common client
    sends one unprompted
  • a header value is taken as it comes: past the stray-CR refusal of RFC 9110 §5.5, only the
    field name is validated, and a value is checked where it is read (Content-Length, Range)
    or not at all

Special thanks for this release: