Skip to content

feat: use values from earlier responses, and keep cookies - #14

Merged
AustinMusiku merged 6 commits into
masterfrom
response-values
Nov 4, 2026
Merged

AustinMusiku merged 6 commits into
masterfrom
response-values

Conversation

@AustinMusiku

Copy link
Copy Markdown
Owner

Sequence files can now use a value from an earlier response, so a flow can log in and then use the token it got. There's also an opt-in cookie jar for APIs that keep the session in a cookie.

# @name login
POST {{base}}/token
Content-Type: application/json

{"email": "[email protected]", "password": "{{$processEnv PASSWORD}}"}

###
# @name account
GET {{base}}/account
Authorization: Bearer {{login.response.body.access_token}}

Values from earlier responses

  • Syntax: {{name.response.body.<path>}} reads JSON from the response of an earlier request named name. body.a.b[0] reads nested keys and lists, body.$.token works as well as body.token, and body.* is the whole body. {{name.response.headers.<Name>}} reads a header. Text goes in as it is; numbers, objects and lists go in as JSON.
  • Rounds and redirects: each round of -n reads its own responses, and after a redirect the value comes from the last hop.
  • Concurrency: a request that reads a value waits for the request it reads, even with -c, while requests that don't depend on anything keep running.
  • Missing values: if the value isn't there (the earlier request failed, or its body has no such key), the request isn't sent. Its row shows ERR with the variable's name and it counts as failed. Values are never printed, in errors or anywhere else; a value placed in a query string shows in the URL, as the README already warns.
  • Checked at load: a name that isn't an earlier # @name, a reused # @name, .request. in place of .response., and a path that can't be read are all errors with the file and line.
  • Memory: only the bodies of requests that another one reads are kept, up to 16 MiB each. A gzipped body is decompressed to read the value, and body_bytes still counts the bytes as sent. Only JSON can be read from; XML is not.
  • Collector: collect.Request gains Build, After and Keep, so the collector stays independent of the file format. -H and -u also apply to requests that are built at send time.

--cookies

  • What it does: keeps the cookies responses set, including on a redirect, and sends them with later requests to the same site for the whole run, later rounds included. Off by default, so rounds stay the same unless asked.
  • Public suffix list: the jar uses golang.org/x/net/publicsuffix, so a site under foo.co.ke can't set cookies for bar.co.ke. This adds golang.org/x/net and raises x/term, x/sys and x/text by minor versions.
  • JSON: request_headers is now copied after the request is sent, so it shows the Cookie the jar added, with values hidden as usual.
  • Concurrency: with -c above 1, a request can still go out before the one that sets its cookie; the docs say so.

The README, --help and the examples are updated to match.

TestConnectionsAreNumbered fails about 4 times in 30 on master as well. If it fails here, it's that existing flaky test, not this change.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@AustinMusiku
AustinMusiku merged commit 5eff47f into master Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants