Skip to content

feat(collection-docs):Res scripting methods improvements - #28

Open
sachin-bruno wants to merge 4 commits into
usebruno:mainfrom
sachin-bruno:sachin-bruno/res-mode-scripting-api
Open

feat(collection-docs):Res scripting methods improvements#28
sachin-bruno wants to merge 4 commits into
usebruno:mainfrom
sachin-bruno:sachin-bruno/res-mode-scripting-api

Conversation

@sachin-bruno

@sachin-bruno sachin-bruno commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Ref: BRU-3837

Problem

The playground's res object did not fully match the app or the browser executor's response shape. It had no structured header list, getHeader was case sensitive, and responseTime and url read fields (responseTime, request) that the browser fetch response does not provide, so they came back null.

Fix

This adds a new read only res.headerList with structured reads (get, all, has, filter, map, and similar), while any attempt to modify response headers throws. It also changes responseTime and url to fall back to the executor's duration and url fields, makes getHeader case insensitive, and updates setBody to deep clone the value and refresh the data buffer so getSize stays correct.

image

@sachin-bruno
sachin-bruno changed the base branch from main to release/v0.2.0 August 6, 2026 10:30
Comment thread packages/bruno-api-docs/src/scripting/utils/bruno-response.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/utils/bruno-response.ts
Comment thread packages/bruno-api-docs/src/scripting/utils/bruno-response.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/utils/bruno-response.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/utils/header-list.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/utils/bruno-response.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/sandbox/quickjs/shims/bruno-response.ts Outdated
Comment thread packages/bruno-api-docs/src/scripting/sandbox/quickjs/shims/bruno-response.ts Outdated

@vasharma05-bruno vasharma05-bruno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Type suggestions for the new functions — the code leans on any in several spots that can be tightened to document the actual shapes flowing through the res object.

@vasharma05-bruno vasharma05-bruno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed, the Buffer management of response data present in this PR is already handled in the RequestExecutor, which is being passed here, and hence the data from RequestExecutor, with type RunRequestResponse must be reused here, rather than recalculating.

@vasharma05-bruno vasharma05-bruno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@arpit-bruno
arpit-bruno changed the base branch from release/v0.2.0 to main August 7, 2026 13:10
@arpit-bruno arpit-bruno closed this Aug 7, 2026
@arpit-bruno arpit-bruno reopened this Aug 7, 2026
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.

3 participants