github unkn0wn-root/resterm v1.18.1

2 hours ago

v1.18.1

This patch fixes gzip responses for requests that set their own Accept-Encoding header, and makes secret masking a bit faster.

Gzip with your own Accept-Encoding

Resterm only decoded gzip when it added Accept-Encoding itself. If the request set that header, the body stayed compressed, so @assert, captures, scripts and the response pane all got gzip bytes. Requests imported with curl --compressed set the header too.

### Users
# @name users
# @assert response.json()[0].name == "david"
GET http://localhost:3000/users
Accept-Encoding: gzip

Before 1.18.1, the check failed:

FAIL GET users [users.http:3:24: invalid json]
  Script Error:
    error[script]: invalid json
    --> users.http:3:24
         |
       3 | # @assert response.json()[0].name == "david"
         |                        ^

Now it passes:

PASS GET users [200 OK in 728.875µs]
  • A gzip response is decoded whether Resterm or the request asked for it. The decoded response has no Content-Encoding or Content-Length header, the same as when Resterm asks for gzip itself.
  • Gzip that can't be decoded used to pass with the broken body. Now the request fails with exit 26:
FAIL GET bad [read response body: invalid gzip header: gzip: invalid header]
  • SSE streams are decoded as they arrive, so events, byteCount and max-bytes use the decoded data, not the compressed bytes. An event stream in an encoding Resterm can't decode, such as br, now fails with exit 26 instead of passing.
  • br, deflate and 206 Partial Content bodies stay as they arrived.
  • curl --compressed imports now write Accept-Encoding: gzip instead of gzip, deflate, br, since Resterm can't decode the other two.
  • With --response, bodySize is the decoded size.

See HTTP settings and streaming.

Faster masking

Masking secrets in JSON is faster. A 1 MiB JSON body now takes about 6 ms instead of 11 ms. This covers --response bodies, history, stream transcripts and trace files.

Upgrading

  1. Decoded gzip responses have no Content-Encoding or Content-Length header. Update checks that read them.
  2. Gzip that can't be decoded fails the request with exit 26. So does an event stream in another encoding, such as br.
  3. Requests imported with curl --compressed before 1.18.1 still ask for gzip, deflate, br. A br or deflate body is kept as it arrived, so change the header to gzip.

If you're upgrading from 1.17.2 or older, read the 1.18.0 notes.

Don't miss a new resterm release

NewReleases is sending notifications on new releases.