github unkn0wn-root/resterm v1.12.1

3 hours ago

v1.12.1

This patch fixes SSE parsing issues and a couple of stale cache problems in mocks and RestermScript modules.

Resterm now follows the SSE specification more closely. Field values keep their whitespace, CR-only streams parse correctly, and BOMs, bare field names, and id values containing null are handled per spec.

If you're upgrading from 1.11.0 or older

1.12.0 changed how helpers such as {{$uuid}} behave in values written by pre-request scripts, @apply, and @patch. They're now treated as plain text.

Use vars.interpolate("{{$uuid}}") when you want a new interpolated value.

Resterm also warns when a script sends a placeholder literally, editor completion includes vars. methods, and JavaScript errors now point back to the relevant line in your request or script file.

SSE field values

Resterm now removes at most one space after a field's colon. Any remaining spaces or tabs are part of the value.

Before this fix, the indentation in this stream was lost:

data: {
data:   "set": 2,
data:   "score": "6-4"
data: }

It now produces:

{
  "set": 2,
  "score": "6-4"
}

The same parsing rule applies to event, id, and comments.

SSE lines and fields

  • CRLF, LF, and CR line endings are all supported. CR-only streams no longer get read as one long line.
  • A byte order mark before the first line is ignored.
  • A line without a colon is treated as a field with an empty value. A bare data line therefore adds an empty line to the event data.
  • An id containing a null character is ignored.

The streaming docs now describes how Resterm reads events and what gets written to the transcript. Comments, blocks with no data field, and unfinished blocks at connection close now behave the same as browser EventSource.

Fixed

  • @sse idle now resets whenever bytes arrive, even if they don't complete a line yet. This avoids timeout:idle on large events that are still being streamed.
  • Empty blocks, including blocks made up only of unknown fields, no longer count toward max-event-bytes.
  • resterm mock --watch and the TUI mock server now notice edits that keep the same file size and happen within two seconds of the previous write. For example, changing 200 to 201 no longer leaves the old response cached.
  • RestermScript modules loaded with @use get the same cache fix. Changes are picked up even when the file size stays the same, and @use without as no longer keeps a stale module name. If a recheck finds that the contents haven't changed, Resterm keeps the compiled module and its top-level state.

Thanks to @bensynapse for the fix to preserve whitespace in SSE field values in PR #448.

Don't miss a new resterm release

NewReleases is sending notifications on new releases.