Skip to content

feat: add PropertyList API for req.headers and res.headers - #7673

Merged
bijin-bruno merged 33 commits into
usebruno:mainfrom
sanish-bruno:feat/headers-list-utils
May 5, 2026
Merged

bijin-bruno merged 33 commits into
usebruno:mainfrom
sanish-bruno:feat/headers-list-utils

Conversation

@sanish-bruno

@sanish-bruno sanish-bruno commented Apr 3, 2026 •

Copy link
Copy Markdown
Collaborator

Jira

Summary

Adds a headerList property to both req and res in scripts, exposing a structured PropertyList API for header management. Method names are aligned with the MDN Web API Headers interface. The existing req.headers and res.headers raw objects remain untouched for full backward compatibility.

New API

req.headerList — writable HeaderList (extends PropertyList, dynamic mode):

// Read
req.headerList.get('Content-Type')              // 'application/json'
req.headerList.has('Authorization')             // true
req.headerList.one('Content-Type')              // { key: 'Content-Type', value: 'application/json' }
req.headerList.all()                            // [{ key, value }, ...]
req.headerList.count()                          // 3

// Search
req.headerList.find(h => h.key.startsWith('X-'))
req.headerList.filter(h => h.value.includes('json'))
req.headerList.indexOf('Content-Type')

// Iteration
req.headerList.forEach((h, i) => { ... })
req.headerList.map(h => h.key)
req.headerList.reduce((acc, h) => ..., {})

// Transform
req.headerList.toObject()                       // { 'Content-Type': 'application/json', ... }
req.headerList.toString()                       // 'Content-Type: application/json\n...'

// Write
req.headerList.append({ key: 'X-Custom', value: 'val' })
req.headerList.append('X-Custom: val')          // string format
req.headerList.append('X-Custom', 'val')        // two-arg form
req.headerList.set({ key: 'Content-Type', value: 'text/plain' })
req.headerList.set('Content-Type', 'text/plain') // two-arg form
req.headerList.delete('X-Custom')
req.headerList.delete(h => h.key.startsWith('X-'))
req.headerList.clear()
req.headerList.populate([{ key: 'A', value: '1' }, ...])
req.headerList.repopulate([{ key: 'A', value: '1' }])
req.headerList.assimilate(otherList, true)

res.headerList — read-only HeaderList (static mode, write methods throw):

res.headerList.get('content-type')              // 'application/json'
res.headerList.has('x-request-id')              // true
res.headerList.all()                            // [{ key, value }, ...]
res.headerList.filter(h => h.key.startsWith('x-'))
res.headerList.toObject()                       // plain object map

Key design decisions

  • Separate property: req.headerList / res.headerList is distinct from req.headers / res.headers — no Proxy layer, no risk of breaking existing scripts
  • MDN-aligned naming: Write methods use append, set, delete, forEach (matching MDN Headers)
  • Case-insensitive: All key lookups are case-insensitive (HTTP headers are case-insensitive)
  • Disabled headers: req.headerList surfaces disabled headers with { disabled: true } — users can query/filter them
  • Dynamic reads: req.headerList reads from the live req.headers object on every access, so mutations via req.setHeader() are always reflected
  • QuickJS support: Full PropertyList bridge wired into the QuickJS sandbox with iterator support and synchronous write hooks

append vs MDN's Headers.append()

MDN's append() creates duplicate headers with the same key. Bruno does not support multiple headers with the same name, so append() delegates to set() — it overwrites any existing header with the same key.

populate and repopulate

  • populate(items) — Adds headers from the array/string, but skips any key that already exists (case-insensitive). Postman's populate adds duplicate keys because Postman supports multiple headers with the same name. Bruno does not, so we skip existing keys to preserve the current value.
  • repopulate(items) — Clears all existing headers first, then adds the new items. Matches Postman's repopulate behavior.

Complete API Reference

All key lookups are case-insensitive per the HTTP spec.

req.headerList — Request Headers (read-write)

Read Methods

Method Returns Description
get(name) string | undefined Value of the first header matching the key
one(name) object | undefined Full header object { key, value } for the matching key
all() object[] Cloned array of all header objects { key, value, disabled? }
count() number Number of headers (including disabled)

Search Methods

Method Returns Description
has(name) boolean true if a header with that key exists
has(name, value) boolean true if key exists and value matches exactly
has(object) boolean true if a header with object.key exists
find(fn, context?) object | undefined First header where the predicate returns truthy
filter(fn, context?) object[] All headers where the predicate returns truthy
indexOf(item) number Index of a header by string key or { key, value } object; -1 if not found

Iteration Methods

Method Returns Description
forEach(fn, context?) void Calls fn(header, index) for every header
map(fn, context?) any[] Returns a new array of mapped values
reduce(fn, initial?, context?) any Reduces headers to a single value

Transform Methods

Method Returns Description
toObject(excludeDisabled?, caseSensitive?, multiValue?, sanitizeKeys?) object Plain { key: value } map
toString() string HTTP wire format Key: Value\n... (skips disabled headers)
toJSON() object[] Same as all() — suitable for JSON.stringify()

Write Methods

Method Returns Description
append(headerObj | name, value?) void Sets a header; accepts { key, value }, "Key: Value" string, or (name, value) two-arg form. Delegates to set() (overwrites existing).
set(headerObj | name, value?) boolean | null Sets or replaces a header. Returns true if new, false if updated, null if input was nil.
delete(predicate, context?) void Deletes header(s) by key string, { key } object, or predicate function
clear() void Removes all headers (enabled and disabled)
populate(items | string) void Adds items from array or multi-line string, skipping keys that already exist
repopulate(items | string) void Clears all headers, then populates with new items
assimilate(source, prune?) void Merges headers from a PropertyList or array; if prune is true, removes headers not present in source

res.headerList — Response Headers (read-only)

All write methods (append, set, delete, clear, populate, repopulate, assimilate) throw a "HeaderList is read-only" error when called on response headers.

Read Methods

Method Returns Description
get(name) string | undefined Value of the first header matching the key
one(name) object | undefined Full header object { key, value } for the matching key
all() object[] Cloned array of all header objects { key, value }
count() number Number of headers

Search Methods

Method Returns Description
has(name) boolean true if a header with that key exists
has(name, value) boolean true if key exists and value matches exactly
has(object) boolean true if a header with object.key exists
find(fn, context?) object | undefined First header where the predicate returns truthy
filter(fn, context?) object[] All headers where the predicate returns truthy
indexOf(item) number Index of a header by string key or { key, value } object; -1 if not found

Iteration Methods

Method Returns Description
forEach(fn, context?) void Calls fn(header, index) for every header
map(fn, context?) any[] Returns a new array of mapped values
reduce(fn, initial?, context?) any Reduces headers to a single value

Transform Methods

Method Returns Description
toObject(excludeDisabled?, caseSensitive?, multiValue?, sanitizeKeys?) object Plain { key: value } map
toString() string HTTP wire format Key: Value\n...
toJSON() object[] Same as all() — suitable for JSON.stringify()

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

@coderabbitai

coderabbitai Bot commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Introduces HeaderList, a new PropertyList subclass for managing HTTP request/response headers with case-insensitive lookups, read/write operations, and optional disabled-header tracking. Integrates HeaderList into BrunoRequest and BrunoResponse, exposes it through the QuickJS VM sandbox, updates header-merging logic to preserve disabled headers, and adds translation mappings and test coverage across the codebase.

Changes

HeaderList Header Abstraction & Integration

Layer / File(s) Summary
Core Abstraction
packages/bruno-js/src/header-list.js
Introduces HeaderList extending PropertyList with case-insensitive read methods (get, one, has, indexOf) and iteration helpers (each, filter, find, map, reduce). Supports two modes: writable dynamic (reflecting source.headers and source.disabledHeaders) and static read-only. Write methods (add, upsert, remove, clear, populate, assimilate) mutate the underlying request object. Transforms via toObject(), toString(), toJSON().
Request/Response Integration
packages/bruno-js/src/bruno-request.js, packages/bruno-js/src/bruno-response.js
BrunoRequest initializes this.headerList = new HeaderList(this) in writable mode; header mutation methods (setHeaders, setHeader, deleteHeader) now write only to req.headers and track deletions. BrunoResponse initializes this.headerList = new HeaderList(res, { writable: false }) in static read-only mode.
Sandbox VM Bridging
packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js, packages/bruno-js/src/sandbox/quickjs/shims/bruno-response.js, packages/bruno-js/src/sandbox/quickjs/utils/property-list-bridge.js
QuickJS shims expose req.headerList and res.headerList via createPropertyListBridge, specifying sync read/write methods and iterator support. Property-list-bridge gains syncWriteMethods option for synchronous mutation registration and conditional function-predicate handling in remove() when iterators are enabled.
Collection Header Merging
packages/bruno-app/src/utils/collections/index.js, packages/bruno-cli/src/utils/collection.js, packages/bruno-cli/src/runner/prepare-request.js, packages/bruno-electron/src/utils/collection.js, packages/bruno-electron/src/ipc/network/prepare-request.js
mergeHeaders() signature extended with options = { includeDisabledHeaders }. When enabled, disabled headers (where enabled: false) are preserved in the merged result; otherwise only enabled headers are returned. Prepare-request functions call mergeHeaders(..., { includeDisabledHeaders: true }) to track disabled headers for downstream use.
API Translations
packages/bruno-converters/src/utils/bruno-to-postman-translator.js, packages/bruno-converters/src/utils/postman-to-bruno-translator.js
Added translation mappings: req.headerList.* (get, has, one, all, idx, count, indexOf, find, filter, each, map, reduce, toObject, add, upsert, remove, clear, populate, repopulate, assimilate) ↔ pm.request.headers.*; res.headerList.* (read-only methods) ↔ pm.response.headers.*.
Developer Experience
packages/bruno-app/src/utils/codemirror/autocomplete.js
Extended STATIC_API_HINTS.req and .res to include all req.headerList.* and res.headerList.* method hints for IDE autocomplete suggestions.
Translation Tests
packages/bruno-converters/tests/bruno/bruno-to-postman-translations/request.test.js, packages/bruno-converters/tests/bruno/bruno-to-postman-translations/response.test.js, packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/request.test.js, packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js, packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/legacy-tests-syntax.test.js
Added test suites for Bruno↔Postman translation of all headerList methods and verified legacy res.getHeaders().has() → res.headerList.has() replacement.
Core Unit Tests
packages/bruno-js/tests/header-list.spec.js
Comprehensive test suite covering BrunoRequest.headerList (writable, dynamic, with disabled-header support) and BrunoResponse.headerList (read-only), including read/write/search/iteration/transform operations, context binding, case-insensitive lookups, disabled-header behavior, and raw header access validation.
Integration & End-to-End Tests
packages/bruno-tests/collection/scripting/api/req/headerList/*.bru, packages/bruno-tests/collection/scripting/api/res/headerList/*.bru, tests/scripting/req-api/headerList/*.spec.ts, tests/scripting/res-api/headerList/*.spec.ts
Added 13 request-side API scripts (add, assimilate, clear, remove, populate, case-insensitive read/write, context binding, disabled headers, iteration, read, search, transform) and 5 response-side scripts (case-insensitive, iteration, read, search, transform) with Playwright E2E test harness validating all 18 requests pass under developer and safe sandbox modes.

Sequence Diagram

sequenceDiagram
    participant User as User Script
    participant Req as BrunoRequest
    participant HL as HeaderList
    participant RawHdrs as req.headers
    participant DH as req.disabledHeaders

    User->>Req: new BrunoRequest(config)
    Req->>HL: new HeaderList(this)
    HL->>RawHdrs: read headers from config
    HL->>DH: read disabledHeaders from config

    User->>HL: upsert({ key, value })
    HL->>HL: `#ciEquals`() for case-insensitive lookup
    HL->>RawHdrs: update headers[key]
    HL->>DH: remove matching disabled entry if exists

    User->>HL: remove(predicate)
    HL->>HL: filter all() with predicate
    HL->>RawHdrs: delete matching headers
    HL->>DH: remove matching disabled headers

    User->>HL: populate(items)
    HL->>HL: clear() first
    HL->>RawHdrs: add new headers
    
    User->>HL: get(name)
    HL->>HL: case-insensitive lookup via all()
    HL-->>User: return matching value or undefined

    User->>HL: toObject()
    HL->>HL: iterate all() with optional filtering
    HL-->>User: return { key: value } map
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • PR #6762: Adds other instance properties and accessors to BrunoRequest alongside header-related modifications.
  • PR #7052: Extends header-related translation enhancements for request/response headers between Bruno and Postman.
  • PR #7073: Modifies the same PropertyList/PropertyListBridge infrastructure that HeaderList now builds upon.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno
  • naman-bruno

Poem

🎯 Headers now shine with a HeaderList crown,
Case-insensitive lookups bringing precision down,
Request, response, disabled—all tracked with care,
Dynamic mutations flow through every layer,
From Postman translations to VM sandboxes fair! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a PropertyList API for request and response headers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sanish-bruno sanish-bruno changed the title feat: introduce HeaderList for dynamic header management in BrunoRequest and BrunoResponse feat: add PropertyList API for req.headers and res.headers Apr 3, 2026

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
packages/bruno-js/src/bruno-response.js (1)

15-23: Minor redundancy: double null-guard on rawHeaders.

Line 17 already defaults rawHeaders to {} when res is falsy, so the || {} on line 21 is unnecessary.

🔧 Suggested simplification
     const headersList = new ReadOnlyPropertyList({
       keyProperty: 'key',
       valueProperty: 'value',
-      items: Object.entries(rawHeaders || {}).map(([key, value]) => ({ key, value }))
+      items: Object.entries(rawHeaders).map(([key, value]) => ({ key, value }))
     });
-    this._headersList = createHeadersProxy(headersList, rawHeaders || {});
+    this._headersList = createHeadersProxy(headersList, rawHeaders);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-js/src/bruno-response.js` around lines 15 - 23, The code
double-null-guards rawHeaders when building headersList and passing to
createHeadersProxy; since rawHeaders is already set to res ? res.headers : {}
use rawHeaders (not rawHeaders || {}) in the ReadOnlyPropertyList.items mapping
and the createHeadersProxy call; update the references around
ReadOnlyPropertyList instantiation and the createHeadersProxy(this._headersList,
...) call so they pass the single rawHeaders variable, keeping symbols
headersList, ReadOnlyPropertyList, createHeadersProxy and rawHeaders intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bruno-js/src/bruno-response.js`:
- Around line 15-23: The code double-null-guards rawHeaders when building
headersList and passing to createHeadersProxy; since rawHeaders is already set
to res ? res.headers : {} use rawHeaders (not rawHeaders || {}) in the
ReadOnlyPropertyList.items mapping and the createHeadersProxy call; update the
references around ReadOnlyPropertyList instantiation and the
createHeadersProxy(this._headersList, ...) call so they pass the single
rawHeaders variable, keeping symbols headersList, ReadOnlyPropertyList,
createHeadersProxy and rawHeaders intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 26689fb4-8708-4bc8-a595-8070201b4484

📥 Commits

Reviewing files that changed from the base of the PR and between c273c10 and 948a730.

📒 Files selected for processing (8)
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-js/src/bruno-response.js
  • packages/bruno-js/src/header-list.js
  • packages/bruno-js/src/headers-proxy.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-response.js
  • packages/bruno-js/src/sandbox/quickjs/utils/property-list-bridge.js
  • packages/bruno-js/tests/header-list.spec.js

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
packages/bruno-js/src/header-list.js (1)

148-151: Consider validating or coercing item.value.

Currently, upsert() allows item.value to be undefined or any type. If setHeader expects a string, you might want to coerce or validate:

this._brunoRequest.setHeader(item.key, item.value ?? '');

Alternatively, if allowing undefined is intentional (e.g., to clear a header), a brief comment would clarify intent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-js/src/header-list.js` around lines 148 - 151, The upsert
method currently passes item.value through unchecked to
this._brunoRequest.setHeader which may expect a string; update upsert (function
upsert) to validate/coerce item.value before calling
this._brunoRequest.setHeader (e.g., convert non-string values to
String(item.value) or use item.value ?? '' to default undefined/null to an empty
string) and add a short comment explaining the chosen behavior (or explicitly
allow undefined to mean header removal) so intent is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bruno-js/src/header-list.js`:
- Around line 148-151: The upsert method currently passes item.value through
unchecked to this._brunoRequest.setHeader which may expect a string; update
upsert (function upsert) to validate/coerce item.value before calling
this._brunoRequest.setHeader (e.g., convert non-string values to
String(item.value) or use item.value ?? '' to default undefined/null to an empty
string) and add a short comment explaining the chosen behavior (or explicitly
allow undefined to mean header removal) so intent is clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0f8ece14-f41a-4b0f-806c-aa340feb39df

📥 Commits

Reviewing files that changed from the base of the PR and between 948a730 and c9dee5f.

📒 Files selected for processing (3)
  • packages/bruno-js/src/header-list.js
  • packages/bruno-js/src/headers-proxy.js
  • packages/bruno-js/tests/header-list.spec.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/bruno-js/src/headers-proxy.js
  • packages/bruno-js/tests/header-list.spec.js

sanish-bruno

This comment was marked as outdated.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-js/src/headers-proxy.js`:
- Around line 69-83: The headers proxy currently falls back to direct mutation
in createHeadersProxy's set and deleteProperty traps (referencing onSet,
onDelete, getRawHeaders), so add a readOnly boolean option to createHeadersProxy
and, when readOnly is true (pass readOnly: true from bruno-response.js where
response headers are created), have set and deleteProperty simply return false
instead of assigning/deleting; when readOnly is false preserve the existing
behavior (call onSet/onDelete if provided else mutate getRawHeaders()) so
callers can opt into immutable response headers.
- Around line 52-53: The proxy traps dereference getRawHeaders() (the getter
passed as () => brunoRequest.req.headers) without guarding against
null/undefined, while setHeaders(headers) can set a falsy value; update every
proxy trap that calls getRawHeaders() (e.g., the get trap used to return
getRawHeaders()[prop], plus other traps handling property access/mutation) to
first obtain const raw = getRawHeaders() and guard with raw || {} (or return
undefined for get) before dereferencing, so operations like get, set, has,
deleteProperty, and ownKeys behave safely when headers are null/undefined;
ensure the behavior matches PropertyList's dataSource fallback semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aacbd9a6-7d8e-4ff5-b31a-db8707d58cf7

📥 Commits

Reviewing files that changed from the base of the PR and between c9dee5f and 321213a.

📒 Files selected for processing (3)
  • packages/bruno-js/src/headers-proxy.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js
  • packages/bruno-js/src/sandbox/quickjs/utils/property-list-bridge.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js

Comment thread packages/bruno-js/src/headers-proxy.js Resolved
Comment thread packages/bruno-js/src/headers-proxy.js Resolved
@sanish-bruno
sanish-bruno requested a review from sid-bruno as a code owner April 21, 2026 08:55

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/bruno-converters/tests/bruno/bruno-to-postman-translations/request.test.js`:
- Around line 233-281: The test suite only covers req.headerList.* translations;
add equivalent tests for the newly exposed req.headers API to ensure parity
(e.g., methods one, find, toObject, upsert plus
get/has/all/filter/add/remove/clear/standalone access). In the tests file
containing the existing cases (the tests invoking translateBruToPostman and
assertions like 'const ct = req.headerList.get("Content-Type");'), duplicate
representative specs but replace req.headerList with req.headers and include new
assertions for req.headers.one(...), req.headers.find(...),
req.headers.toObject(), and req.headers.upsert({...}) using the same
translateBruToPostman and expect pattern to assert they map to
pm.request.headers.* equivalents; keep naming consistent with existing it(...)
descriptions so CI/test reporting is clear.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9f538308-608d-4554-8680-7f07c9ebd698

📥 Commits

Reviewing files that changed from the base of the PR and between 321213a and aa848a8.

📒 Files selected for processing (13)
  • packages/bruno-converters/src/utils/bruno-to-postman-translator.js
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/request.test.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/response.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/legacy-tests-syntax.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/request.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-js/src/bruno-response.js
  • packages/bruno-js/src/header-list.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-response.js
  • packages/bruno-js/tests/header-list.spec.js
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-js/tests/header-list.spec.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js
  • packages/bruno-js/src/bruno-response.js

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/bruno-js/src/bruno-request.js (2)

21-21: ⚠️ Potential issue | 🟠 Major

this.headers can drift from this.req.headers after setHeaders().

Constructor captures this.headers = req.headers (a reference). setHeaders(headers) reassigns only this.req.headers, so the public req.headers shorthand documented on Line 8 keeps pointing at the old object. Subsequent reads via req.headers[...] or Object.keys(req.headers) in user scripts will silently observe stale data, and headerList (constructed with this) will read through this.req.headers — i.e. the new object — so the two APIs will disagree.

🛠️ Suggested fix
   setHeaders(headers) {
     this.req.headers = headers;
+    this.headers = headers;
   }

Same concern technically applies to setHeader/deleteHeader, but those mutate in place so the shared reference still works — only full reassignment breaks it.

Also applies to: 131-133

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-js/src/bruno-request.js` at line 21, The constructor currently
does this.headers = req.headers which creates a stale reference when
setHeaders(headers) reassigns this.req.headers; fix by making the public
shorthand always reflect the current request headers — either convert headers
into a getter that returns this.req.headers (so headerList and external reads
always see the live object) or ensure setHeaders(headers) also updates
this.headers to point at the new object; apply the same fix/consistency to the
other places noted (e.g., the code around setHeader/deleteHeader and the block
at lines ~131-133) so no API surface can drift from this.req.headers.

101-120: ⚠️ Potential issue | 🟡 Minor

Add case-insensitive header lookup to getAuthMode() for consistency.

getAuthMode() checks headers?.['Authorization'] and headers?.['X-WSSE'] with exact casing, but the same file's hasJSONContentType() (line 164) checks both 'Content-Type' and 'content-type' to handle case variations. Since users can set headers with any casing via req.setHeader(name, value), add a fallback to lowercase lookups:

} else if (headers?.['Authorization']?.startsWith('Bearer') || headers?.['authorization']?.startsWith('Bearer')) {
  return 'bearer';
} else if (headers?.['Authorization']?.startsWith('Basic') || headers?.['authorization']?.startsWith('Basic') || this.req?.auth?.username) {
  return 'basic';

Apply the same pattern to X-WSSE.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-js/src/bruno-request.js` around lines 101 - 120, Update
getAuthMode() to perform case-insensitive header checks for Authorization and
X-WSSE like hasJSONContentType() does: when checking for bearer/basic auth and
WSSE, also consult headers['authorization'] and headers['x-wsse'] fallbacks (in
addition to headers['Authorization'] and headers['X-WSSE']) so
startsWith('Bearer')/startsWith('Basic')/presence checks work regardless of
header casing; modify the branches in getAuthMode() accordingly (preserving
existing checks on this.req.oauth2, oauth1config, auth.username, awsv4,
digestConfig) so behavior is identical but tolerant to header case variations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-js/src/bruno-response.js`:
- Line 10: The constructor sets this.headers = res ? res.headers : {} while
getHeaders() returns null when res is absent, creating an inconsistent contract;
change the constructor assignment to this.headers = res ? res.headers : null so
this.headers and getHeaders() both return null when res is missing (refer to the
this.headers initialization and the getHeaders() method to locate the code).

---

Outside diff comments:
In `@packages/bruno-js/src/bruno-request.js`:
- Line 21: The constructor currently does this.headers = req.headers which
creates a stale reference when setHeaders(headers) reassigns this.req.headers;
fix by making the public shorthand always reflect the current request headers —
either convert headers into a getter that returns this.req.headers (so
headerList and external reads always see the live object) or ensure
setHeaders(headers) also updates this.headers to point at the new object; apply
the same fix/consistency to the other places noted (e.g., the code around
setHeader/deleteHeader and the block at lines ~131-133) so no API surface can
drift from this.req.headers.
- Around line 101-120: Update getAuthMode() to perform case-insensitive header
checks for Authorization and X-WSSE like hasJSONContentType() does: when
checking for bearer/basic auth and WSSE, also consult headers['authorization']
and headers['x-wsse'] fallbacks (in addition to headers['Authorization'] and
headers['X-WSSE']) so startsWith('Bearer')/startsWith('Basic')/presence checks
work regardless of header casing; modify the branches in getAuthMode()
accordingly (preserving existing checks on this.req.oauth2, oauth1config,
auth.username, awsv4, digestConfig) so behavior is identical but tolerant to
header case variations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13386519-96d1-4ba4-b4d1-55e2e4cdca55

📥 Commits

Reviewing files that changed from the base of the PR and between aa848a8 and 0a92d58.

📒 Files selected for processing (3)
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-js/src/bruno-response.js
  • packages/bruno-js/tests/header-list.spec.js
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-js/tests/header-list.spec.js

Comment thread packages/bruno-js/src/bruno-response.js Resolved
…est and BrunoResponse

- Implemented HeaderList to provide a dynamic API for managing request headers, allowing real-time reflection of changes.
- Updated BrunoRequest and BrunoResponse to utilize HeaderList for header access, enhancing consistency and usability.
- Added a headers proxy to maintain backward compatibility with existing header access patterns.
- Introduced tests for HeaderList to ensure functionality and reliability across various header operations.
…aw headers

- Modified createHeadersProxy to allow passing a function that retrieves raw headers, enhancing flexibility in header management.
- Updated HeaderList to utilize the new getter function, ensuring consistent behavior when headers are modified.
- Added a test to verify that bracket access reflects changes made via BrunoRequest.setHeaders.
…der management

- Updated createHeadersProxy to clarify precedence of PropertyList methods over header names in bracket access.
- Expanded syncWriteMethods in bruno-request shim to include additional methods for better header manipulation.
- Implemented a custom remove method in property-list-bridge to handle function predicates in-VM, improving the native bridge's functionality.
- Renamed `req.headers` to `req.headerList` for improved clarity and consistency in header operations.
- Enhanced `HeaderList` to support both dynamic and static modes for header management.
- Updated shims for `req` and `res` to reflect the new header access patterns.
- Modified tests to validate the new header access methods and ensure backward compatibility with raw headers.
…noResponse

- Added comprehensive translations for `req.headerList` and `res.headerList` methods to their respective Postman equivalents, improving consistency in header management.
- Updated tests to validate the new translation methods, ensuring accurate conversion between Bruno and Postman header operations.
- Enhanced existing tests to cover additional header manipulation scenarios, reinforcing the reliability of the header management system.
…unoResponse

- Replaced lazy initialization of `headerList` with direct instantiation in both classes for improved performance and clarity.
- Removed redundant getter methods for `headerList`, simplifying the API.
- Updated tests to reflect changes in headerList instantiation and ensure proper functionality.
@sanish-bruno
sanish-bruno force-pushed the feat/headers-list-utils branch from 41bf434 to b74f8c1 Compare April 24, 2026 12:40
- Introduced multiple test files for `req.headerList` and `res.headerList` methods, covering various operations such as add, remove, clear, populate, and search methods.
- Implemented tests for both dynamic and read-only scenarios, ensuring robust validation of header management functionalities.
- Enhanced existing headerList methods with detailed assertions to improve reliability and maintainability of the header management system.
…req and res

- Added a comprehensive list of methods for `req.headerList` and `res.headerList` to enhance autocomplete functionality.
- Included various operations such as get, add, remove, and manipulation methods to improve developer experience and usability.
- Added functionality to track disabled headers in `req.headerList` and `res.headerList`, allowing for better management of header states.
- Updated the `prepareRequest` and `prepareGrpcRequest` functions to include a `disabledHeaders` property.
- Enhanced the `HeaderList` class to handle disabled headers, including methods to filter, count, and retrieve them.
- Introduced tests to validate the behavior of disabled headers, ensuring they are correctly included in the header list while being excluded from raw headers.
…ed toObject method

- Implemented case-insensitive key lookups for methods such as get, one, has, and indexOf in HeaderList.
- Updated toObject method to support options for excluding disabled headers, handling duplicate keys, and skipping headers with falsy keys.
- Modified toString method to return headers in HTTP wire format, improving consistency with standard practices.
- Added comprehensive tests to validate new functionalities, ensuring robust header management and accurate behavior for both enabled and disabled headers.
- Enhanced iteration methods (each, filter, find, map, reduce) in HeaderList to accept an optional context parameter, allowing for better control over the `this` binding in callback functions.
- Updated the remove method to support context binding for function predicates.
- Added comprehensive tests to validate the new context binding functionality across various iteration methods, ensuring robust header management.
…ect support

- Added support for accepting an object with a key property in the `has` method, improving header existence checks.
- Updated `add` and `populate` methods to accept "Key: Value" strings and multi-line header strings, enhancing flexibility in header management.
- Modified `toString` method to ensure a trailing newline in the output, aligning with HTTP wire format standards.
- Introduced comprehensive tests to validate new functionalities, ensuring robust header management and accurate behavior for various input types.
… context binding

- Updated `mergeHeaders` function to preserve disabled headers from the request item, improving header state management.
- Modified `addBrunoRequestShimToContext` and `addBrunoResponseShimToContext` to wrap eval code in blocks, preventing redeclaration conflicts.
- Enhanced iteration methods in `property-list-bridge` to support context binding, allowing for better control over `this` in callbacks.
- Added comprehensive tests for `req.headerList` and `res.headerList` to validate new functionalities and ensure robust header management.
…t items

- Enhanced the `mergeHeaders` function to retain disabled headers from the last entry in the request tree path, ensuring better management of header states.
- Updated the logic to include disabled headers while merging, improving the overall functionality of header management.
…ders

- Refactored the `mergeHeaders` function to utilize a separate array for disabled headers, ensuring they are preserved during the merging process.
- Simplified the logic for merging headers by directly combining enabled and disabled headers into the request object, enhancing clarity and maintainability.
- Changed the implementation of disabled headers from an array to a Map for better performance and consistency.
- Updated the logic in the `mergeHeaders` function to ensure disabled headers are correctly merged into the request object.
- Enhanced tests to validate the handling of disabled headers, including new scenarios for folder-level and request-level overrides.
…disabled headers

- Updated the `mergeHeaders` function to accept an options parameter, allowing for the inclusion of disabled headers in the merged result.
- Modified the logic to handle disabled headers more effectively, ensuring they can be returned based on the provided options.
- Adjusted calls to `mergeHeaders` in various modules to utilize the new functionality, improving header management consistency across the application.
- Eliminated the handling of disabledHeaders in the prepareGrpcRequest function to streamline header management.
- Updated the headers processing logic to focus solely on enabled headers, enhancing clarity and reducing complexity.
- Introduced new tests to translate methods from req.headerList and res.headerList to their corresponding pm.request.headers and pm.response.headers methods.
- Added translations for methods: one, find, toObject, and upsert, enhancing the functionality of the header management system.
- Enhanced documentation for `prepend`, `append`, `insert`, and `insertAfter` methods to clarify that they are aliases for `add()` and include a note on the lack of support for ordering and duplicates.
- Updated method comments to reflect the internal handling of headers as a plain object, ensuring better understanding of header management behavior.
- Eliminated redundant initialization of headerList in the BrunoRequest constructor, ensuring cleaner code and preventing potential issues with header management.
- This change simplifies the constructor logic while maintaining the intended functionality of the headerList.
…ation

- Removed the unimplemented methods `prepend`, `append`, `insert`, and `insertAfter` from the headerList, ensuring clarity in the API.
- Updated documentation to reflect that these methods are not implemented and provide guidance to use `add()` or `upsert()` instead.
- Adjusted tests to verify that calls to these methods throw appropriate not-implemented errors, enhancing the robustness of header management.
- Eliminated the call to `req.headerList.append()` in the pre-request script, streamlining the header management process.
- This change aligns with the recent refactor to remove unimplemented methods, ensuring clarity and consistency in the API usage.
- Changed error messages in tests for `append`, `prepend`, `insert`, and `insertAfter` methods to indicate they are "not yet implemented" instead of "not implemented".
- This update improves clarity in the test outputs, aligning with the current state of the headerList API.
…tests

- Eliminated the unimplemented methods `prepend`, `append`, `insert`, and `insertAfter` from the HeaderList class and corresponding tests, clarifying the API usage.
- Updated the documentation to guide users towards using `add()` or `upsert()` instead.
- Adjusted tests to remove references to these methods, ensuring they accurately reflect the current state of the headerList API.
- Modified the HeaderList class to accept the raw request and response objects directly, simplifying the initialization process.
- Updated the BrunoRequest and BrunoResponse classes to reflect this change, ensuring consistent handling of headers.
- Enhanced internal methods to utilize the new structure, improving clarity and maintainability of the header management system.
@sanish-bruno

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/bruno-js/src/header-list.js (1)

98-107: 💤 Low value

Consider documenting the ordering rationale.

The dataSource places disabled headers before enabled ones ([...disabled, ...enabled]). Combined with findLast() in get()/one(), this correctly prioritizes enabled headers over disabled ones with the same key. The intent is clear but a brief inline comment would help future maintainers understand this deliberate ordering.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-js/src/header-list.js` around lines 98 - 107, Add a brief
inline comment in the dataSource function explaining why disabled headers are
placed before enabled ones (returning [...disabled, ...enabled]) so that
combined with findLast() used in get()/one(), enabled headers override disabled
ones for the same key; reference the dataSource function and the get()/one()
usages of findLast() to make the intentional ordering explicit for future
maintainers.
tests/scripting/req-api/headerList/headerList.spec.ts (1)

5-25: ⚡ Quick win

Wrap each step in test.step per project test guidelines.

Neither test uses test.step, which means the Playwright HTML report shows a flat list of assertions rather than labelled phases. Given the clear sequential flow, this is a quick win.

♻️ Proposed refactor
  test('all req.headerList tests pass in developer mode', async ({ pageWithUserData: page }) => {
-   await setSandboxMode(page, 'bruno-testbench', 'developer');
-   await selectEnvironment(page, 'Prod');
-   await runFolder(page, 'bruno-testbench', ['scripting', 'api', 'req', 'headerList']);
-   await validateRunnerResults(page, {
-     totalRequests: 13,
-     passed: 13,
-     failed: 0
-   });
+   await test.step('set sandbox to developer mode', () =>
+     setSandboxMode(page, 'bruno-testbench', 'developer'));
+   await test.step('select Prod environment', () =>
+     selectEnvironment(page, 'Prod'));
+   await test.step('run headerList folder', () =>
+     runFolder(page, 'bruno-testbench', ['scripting', 'api', 'req', 'headerList']));
+   await test.step('validate runner results', () =>
+     validateRunnerResults(page, { totalRequests: 13, passed: 13, failed: 0 }));
  });

  test('all req.headerList tests pass in safe mode', async ({ pageWithUserData: page }) => {
-   await setSandboxMode(page, 'bruno-testbench', 'safe');
-   await selectEnvironment(page, 'Prod');
-   await runFolder(page, 'bruno-testbench', ['scripting', 'api', 'req', 'headerList']);
-   await validateRunnerResults(page, {
-     totalRequests: 13,
-     passed: 13,
-     failed: 0
-   });
+   await test.step('set sandbox to safe mode', () =>
+     setSandboxMode(page, 'bruno-testbench', 'safe'));
+   await test.step('select Prod environment', () =>
+     selectEnvironment(page, 'Prod'));
+   await test.step('run headerList folder', () =>
+     runFolder(page, 'bruno-testbench', ['scripting', 'api', 'req', 'headerList']));
+   await test.step('validate runner results', () =>
+     validateRunnerResults(page, { totalRequests: 13, passed: 13, failed: 0 }));
  });

As per coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/scripting/req-api/headerList/headerList.spec.ts` around lines 5 - 25,
The tests "all req.headerList tests pass in developer mode" and "all
req.headerList tests pass in safe mode" should wrap each logical operation in a
test.step to improve reporting: replace the direct awaits to setSandboxMode,
selectEnvironment, runFolder, and validateRunnerResults with individual
test.step blocks (use the same descriptive labels) inside each test function so
steps like setSandboxMode(page, 'bruno-testbench', 'developer'|'safe'),
selectEnvironment(page, 'Prod'), runFolder(page,
['scripting','api','req','headerList']), and validateRunnerResults(page, {...})
are executed inside test.step callbacks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-js/tests/header-list.spec.js`:
- Around line 672-684: Update the upsert() implementation to track removed
headers the same way remove() does: when you detect an existing header with
different casing (the local variable existingKey in upsert()), call the private
helper `#deleteHeader`(existingKey) instead of directly deleting
headers[existingKey] so the original casing is recorded in
rawReq.__headersToDelete; keep the existing `#deleteHeaderCI`() logic unchanged.
Then update the tests: after calling list.remove('content-type') add an
assertion that rawReq.__headersToDelete contains 'Content-Type', and after
calling list.upsert({ key: 'content-type', value: 'text/plain' }) add an
assertion that rawReq.__headersToDelete contains 'Content-Type' to verify
case-insensitive tracking.

In
`@packages/bruno-tests/collection/scripting/api/req/headerList/disabled-headers.bru`:
- Around line 46-50: The test "req.headerList.count() includes disabled headers"
is recomputing the count from req.headerList.all() instead of calling
req.headerList.count(), which hides regressions in the bridge; update the
assertion to call req.headerList.count() and assert it equals 5 (e.g., const
count = req.headerList.count(); expect(count).to.equal(5)), leaving the rest of
the test and the brunoHeaders filtering unchanged so the test still documents
which headers are expected.

---

Nitpick comments:
In `@packages/bruno-js/src/header-list.js`:
- Around line 98-107: Add a brief inline comment in the dataSource function
explaining why disabled headers are placed before enabled ones (returning
[...disabled, ...enabled]) so that combined with findLast() used in get()/one(),
enabled headers override disabled ones for the same key; reference the
dataSource function and the get()/one() usages of findLast() to make the
intentional ordering explicit for future maintainers.

In `@tests/scripting/req-api/headerList/headerList.spec.ts`:
- Around line 5-25: The tests "all req.headerList tests pass in developer mode"
and "all req.headerList tests pass in safe mode" should wrap each logical
operation in a test.step to improve reporting: replace the direct awaits to
setSandboxMode, selectEnvironment, runFolder, and validateRunnerResults with
individual test.step blocks (use the same descriptive labels) inside each test
function so steps like setSandboxMode(page, 'bruno-testbench',
'developer'|'safe'), selectEnvironment(page, 'Prod'), runFolder(page,
['scripting','api','req','headerList']), and validateRunnerResults(page, {...})
are executed inside test.step callbacks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 58fa761d-387f-4081-9379-6de91ade736a

📥 Commits

Reviewing files that changed from the base of the PR and between aa848a8 and 0f70f0b.

📒 Files selected for processing (45)
  • packages/bruno-app/src/utils/codemirror/autocomplete.js
  • packages/bruno-app/src/utils/collections/index.js
  • packages/bruno-cli/src/runner/prepare-request.js
  • packages/bruno-cli/src/utils/collection.js
  • packages/bruno-converters/src/utils/bruno-to-postman-translator.js
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/request.test.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/response.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/legacy-tests-syntax.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/request.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
  • packages/bruno-electron/src/ipc/network/prepare-request.js
  • packages/bruno-electron/src/utils/collection.js
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-js/src/bruno-response.js
  • packages/bruno-js/src/header-list.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js
  • packages/bruno-js/src/sandbox/quickjs/shims/bruno-response.js
  • packages/bruno-js/src/sandbox/quickjs/utils/property-list-bridge.js
  • packages/bruno-js/tests/header-list.spec.js
  • packages/bruno-tests/collection/scripting/api/req/headerList/add.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/assimilate.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/case-insensitive-write.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/case-insensitive.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/clear.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/context-binding.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/disabled-headers.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/folder.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/iteration-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/populate.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/read-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/remove.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/search-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/transform-methods.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/case-insensitive.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/iteration-methods.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/read-methods.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/search-methods.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/transform-methods.bru
  • tests/scripting/req-api/headerList/headerList.spec.ts
  • tests/scripting/req-api/headerList/init-user-data/collection-security.json
  • tests/scripting/req-api/headerList/init-user-data/preferences.json
  • tests/scripting/res-api/headerList/headerList.spec.ts
  • tests/scripting/res-api/headerList/init-user-data/collection-security.json
  • tests/scripting/res-api/headerList/init-user-data/preferences.json
✅ Files skipped from review due to trivial changes (20)
  • tests/scripting/res-api/headerList/init-user-data/collection-security.json
  • tests/scripting/req-api/headerList/init-user-data/preferences.json
  • packages/bruno-tests/collection/scripting/api/req/headerList/add.bru
  • tests/scripting/req-api/headerList/init-user-data/collection-security.json
  • packages/bruno-tests/collection/scripting/api/req/headerList/folder.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/iteration-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/populate.bru
  • packages/bruno-tests/collection/scripting/api/res/headerList/read-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/context-binding.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/search-methods.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/remove.bru
  • tests/scripting/res-api/headerList/init-user-data/preferences.json
  • packages/bruno-tests/collection/scripting/api/res/headerList/search-methods.bru
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/legacy-tests-syntax.test.js
  • packages/bruno-tests/collection/scripting/api/req/headerList/iteration-methods.bru
  • tests/scripting/res-api/headerList/headerList.spec.ts
  • packages/bruno-tests/collection/scripting/api/req/headerList/assimilate.bru
  • packages/bruno-tests/collection/scripting/api/req/headerList/read-methods.bru
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/request.test.js
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/response.test.js
  • packages/bruno-converters/src/utils/bruno-to-postman-translator.js
  • packages/bruno-js/src/bruno-request.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/request.test.js

- Updated HeaderList to track removed headers for axios interceptor, improving header casing handling.
- Added new syncWriteMethods to the BrunoResponse shim for better integration.
- Enhanced tests to verify the correct tracking of deleted headers and updated expectations for header management functionality.
- Removed unused 'idx' translations from both bruno-to-postman and postman-to-bruno translators to streamline header management.
- Enhanced the HeaderList class to skip existing keys when populating headers, ensuring that current values are preserved.
- Updated tests to reflect the new behavior of the populate method, verifying that existing headers are not overwritten and adjusting expectations accordingly.
- Modified the req.headerList.populate method to add new headers while preserving existing ones, ensuring that current values are not overwritten.
- Updated the associated test to reflect this new behavior, verifying that existing headers remain intact and new headers are correctly added.
- Renamed `each` method to `forEach` in HeaderList for consistency with standard JavaScript array methods.
- Updated header management methods: replaced `add` with `append`, `upsert` with `set`, and `remove` with `delete` to better reflect their functionality.
- Enhanced translations in bruno-to-postman and postman-to-bruno converters to align with the new method names.
- Adjusted tests to verify the new method names and ensure correct header management behavior.
- Removed the `entries`, `keys`, and `values` methods from the HeaderList class to streamline the API and eliminate unused functionality.
- Updated the `bruno-request` and `bruno-response` shims to reflect the removal of these methods, ensuring consistency in header management.
- Adjusted tests to remove references to the deleted methods, maintaining alignment with the current state of the headerList API.
- Updated the HeaderList class to remove headers from the __headersToDelete array when they are re-added, preventing incorrect header deletion behavior.
- Added tests to verify that re-added headers do not remain in __headersToDelete and that their values are correctly set in the raw request headers.
@bijin-bruno
bijin-bruno merged commit eb06a3f into usebruno:main May 5, 2026
10 of 11 checks passed
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
…7673)

* feat: introduce HeaderList for dynamic header management in BrunoRequest and BrunoResponse

- Implemented HeaderList to provide a dynamic API for managing request headers, allowing real-time reflection of changes.
- Updated BrunoRequest and BrunoResponse to utilize HeaderList for header access, enhancing consistency and usability.
- Added a headers proxy to maintain backward compatibility with existing header access patterns.
- Introduced tests for HeaderList to ensure functionality and reliability across various header operations.

* refactor: update createHeadersProxy to accept a getter function for raw headers

- Modified createHeadersProxy to allow passing a function that retrieves raw headers, enhancing flexibility in header management.
- Updated HeaderList to utilize the new getter function, ensuring consistent behavior when headers are modified.
- Added a test to verify that bracket access reflects changes made via BrunoRequest.setHeaders.

* refactor: enhance headers proxy and syncWriteMethods for improved header management

- Updated createHeadersProxy to clarify precedence of PropertyList methods over header names in bracket access.
- Expanded syncWriteMethods in bruno-request shim to include additional methods for better header manipulation.
- Implemented a custom remove method in property-list-bridge to handle function predicates in-VM, improving the native bridge's functionality.

* refactor: update header management in BrunoRequest and BrunoResponse

- Renamed `req.headers` to `req.headerList` for improved clarity and consistency in header operations.
- Enhanced `HeaderList` to support both dynamic and static modes for header management.
- Updated shims for `req` and `res` to reflect the new header access patterns.
- Modified tests to validate the new header access methods and ensure backward compatibility with raw headers.

* refactor: enhance header translation methods for BrunoRequest and BrunoResponse

- Added comprehensive translations for `req.headerList` and `res.headerList` methods to their respective Postman equivalents, improving consistency in header management.
- Updated tests to validate the new translation methods, ensuring accurate conversion between Bruno and Postman header operations.
- Enhanced existing tests to cover additional header manipulation scenarios, reinforcing the reliability of the header management system.

* refactor: streamline headerList implementation in BrunoRequest and BrunoResponse

- Replaced lazy initialization of `headerList` with direct instantiation in both classes for improved performance and clarity.
- Removed redundant getter methods for `headerList`, simplifying the API.
- Updated tests to reflect changes in headerList instantiation and ensure proper functionality.

* refactor: remove header proxy

* feat: add comprehensive headerList tests for request and response

- Introduced multiple test files for `req.headerList` and `res.headerList` methods, covering various operations such as add, remove, clear, populate, and search methods.
- Implemented tests for both dynamic and read-only scenarios, ensuring robust validation of header management functionalities.
- Enhanced existing headerList methods with detailed assertions to improve reliability and maintainability of the header management system.

* feat: expand STATIC_API_HINTS with additional headerList methods for req and res

- Added a comprehensive list of methods for `req.headerList` and `res.headerList` to enhance autocomplete functionality.
- Included various operations such as get, add, remove, and manipulation methods to improve developer experience and usability.

* feat: implement support for disabled headers in headerList

- Added functionality to track disabled headers in `req.headerList` and `res.headerList`, allowing for better management of header states.
- Updated the `prepareRequest` and `prepareGrpcRequest` functions to include a `disabledHeaders` property.
- Enhanced the `HeaderList` class to handle disabled headers, including methods to filter, count, and retrieve them.
- Introduced tests to validate the behavior of disabled headers, ensuring they are correctly included in the header list while being excluded from raw headers.

* feat: enhance HeaderList with case-insensitive key lookups and improved toObject method

- Implemented case-insensitive key lookups for methods such as get, one, has, and indexOf in HeaderList.
- Updated toObject method to support options for excluding disabled headers, handling duplicate keys, and skipping headers with falsy keys.
- Modified toString method to return headers in HTTP wire format, improving consistency with standard practices.
- Added comprehensive tests to validate new functionalities, ensuring robust header management and accurate behavior for both enabled and disabled headers.

* feat: add context binding to iteration methods in HeaderList

- Enhanced iteration methods (each, filter, find, map, reduce) in HeaderList to accept an optional context parameter, allowing for better control over the `this` binding in callback functions.
- Updated the remove method to support context binding for function predicates.
- Added comprehensive tests to validate the new context binding functionality across various iteration methods, ensuring robust header management.

* feat: enhance HeaderList with new methods for string handling and object support

- Added support for accepting an object with a key property in the `has` method, improving header existence checks.
- Updated `add` and `populate` methods to accept "Key: Value" strings and multi-line header strings, enhancing flexibility in header management.
- Modified `toString` method to ensure a trailing newline in the output, aligning with HTTP wire format standards.
- Introduced comprehensive tests to validate new functionalities, ensuring robust header management and accurate behavior for various input types.

* feat: enhance header management with support for disabled headers and context binding

- Updated `mergeHeaders` function to preserve disabled headers from the request item, improving header state management.
- Modified `addBrunoRequestShimToContext` and `addBrunoResponseShimToContext` to wrap eval code in blocks, preventing redeclaration conflicts.
- Enhanced iteration methods in `property-list-bridge` to support context binding, allowing for better control over `this` in callbacks.
- Added comprehensive tests for `req.headerList` and `res.headerList` to validate new functionalities and ensure robust header management.

* feat: improve header merging to preserve disabled headers from request items

- Enhanced the `mergeHeaders` function to retain disabled headers from the last entry in the request tree path, ensuring better management of header states.
- Updated the logic to include disabled headers while merging, improving the overall functionality of header management.

* feat: update header merging logic to consistently handle disabled headers

- Refactored the `mergeHeaders` function to utilize a separate array for disabled headers, ensuring they are preserved during the merging process.
- Simplified the logic for merging headers by directly combining enabled and disabled headers into the request object, enhancing clarity and maintainability.

* refactor: update disabled headers handling in mergeHeaders function

- Changed the implementation of disabled headers from an array to a Map for better performance and consistency.
- Updated the logic in the `mergeHeaders` function to ensure disabled headers are correctly merged into the request object.
- Enhanced tests to validate the handling of disabled headers, including new scenarios for folder-level and request-level overrides.

* feat: enhance mergeHeaders function to support optional inclusion of disabled headers

- Updated the `mergeHeaders` function to accept an options parameter, allowing for the inclusion of disabled headers in the merged result.
- Modified the logic to handle disabled headers more effectively, ensuring they can be returned based on the provided options.
- Adjusted calls to `mergeHeaders` in various modules to utilize the new functionality, improving header management consistency across the application.

* refactor: remove disabledHeaders from prepareGrpcRequest function

- Eliminated the handling of disabledHeaders in the prepareGrpcRequest function to streamline header management.
- Updated the headers processing logic to focus solely on enabled headers, enhancing clarity and reducing complexity.

* feat: add translations for req.headerList and res.headerList methods

- Introduced new tests to translate methods from req.headerList and res.headerList to their corresponding pm.request.headers and pm.response.headers methods.
- Added translations for methods: one, find, toObject, and upsert, enhancing the functionality of the header management system.

* docs: update HeaderList method aliases and add clarification notes

- Enhanced documentation for `prepend`, `append`, `insert`, and `insertAfter` methods to clarify that they are aliases for `add()` and include a note on the lack of support for ordering and duplicates.
- Updated method comments to reflect the internal handling of headers as a plain object, ensuring better understanding of header management behavior.

* fix: remove duplicate headerList initialization in BrunoRequest class

- Eliminated redundant initialization of headerList in the BrunoRequest constructor, ensuring cleaner code and preventing potential issues with header management.
- This change simplifies the constructor logic while maintaining the intended functionality of the headerList.

* refactor: remove unimplemented headerList methods and update documentation

- Removed the unimplemented methods `prepend`, `append`, `insert`, and `insertAfter` from the headerList, ensuring clarity in the API.
- Updated documentation to reflect that these methods are not implemented and provide guidance to use `add()` or `upsert()` instead.
- Adjusted tests to verify that calls to these methods throw appropriate not-implemented errors, enhancing the robustness of header management.

* refactor: remove unused headerList append method from pre-request script

- Eliminated the call to `req.headerList.append()` in the pre-request script, streamlining the header management process.
- This change aligns with the recent refactor to remove unimplemented methods, ensuring clarity and consistency in the API usage.

* test: update error messages for unimplemented headerList methods

- Changed error messages in tests for `append`, `prepend`, `insert`, and `insertAfter` methods to indicate they are "not yet implemented" instead of "not implemented".
- This update improves clarity in the test outputs, aligning with the current state of the headerList API.

* refactor: remove unimplemented headerList methods and update related tests

- Eliminated the unimplemented methods `prepend`, `append`, `insert`, and `insertAfter` from the HeaderList class and corresponding tests, clarifying the API usage.
- Updated the documentation to guide users towards using `add()` or `upsert()` instead.
- Adjusted tests to remove references to these methods, ensuring they accurately reflect the current state of the headerList API.

* refactor: update HeaderList to accept raw request and response objects

- Modified the HeaderList class to accept the raw request and response objects directly, simplifying the initialization process.
- Updated the BrunoRequest and BrunoResponse classes to reflect this change, ensuring consistent handling of headers.
- Enhanced internal methods to utilize the new structure, improving clarity and maintainability of the header management system.

* refactor: enhance HeaderList header management and update tests

- Updated HeaderList to track removed headers for axios interceptor, improving header casing handling.
- Added new syncWriteMethods to the BrunoResponse shim for better integration.
- Enhanced tests to verify the correct tracking of deleted headers and updated expectations for header management functionality.

* refactor: update header translations and improve HeaderList methods

- Removed unused 'idx' translations from both bruno-to-postman and postman-to-bruno translators to streamline header management.
- Enhanced the HeaderList class to skip existing keys when populating headers, ensuring that current values are preserved.
- Updated tests to reflect the new behavior of the populate method, verifying that existing headers are not overwritten and adjusting expectations accordingly.

* refactor: update headerList.populate behavior and adjust tests

- Modified the req.headerList.populate method to add new headers while preserving existing ones, ensuring that current values are not overwritten.
- Updated the associated test to reflect this new behavior, verifying that existing headers remain intact and new headers are correctly added.

* refactor: update HeaderList methods and translations for consistency

- Renamed `each` method to `forEach` in HeaderList for consistency with standard JavaScript array methods.
- Updated header management methods: replaced `add` with `append`, `upsert` with `set`, and `remove` with `delete` to better reflect their functionality.
- Enhanced translations in bruno-to-postman and postman-to-bruno converters to align with the new method names.
- Adjusted tests to verify the new method names and ensure correct header management behavior.

* refactor: remove unused headerList methods and update related shims

- Removed the `entries`, `keys`, and `values` methods from the HeaderList class to streamline the API and eliminate unused functionality.
- Updated the `bruno-request` and `bruno-response` shims to reflect the removal of these methods, ensuring consistency in header management.
- Adjusted tests to remove references to the deleted methods, maintaining alignment with the current state of the headerList API.

* fix: ensure re-added headers are removed from __headersToDelete

- Updated the HeaderList class to remove headers from the __headersToDelete array when they are re-added, preventing incorrect header deletion behavior.
- Added tests to verify that re-added headers do not remain in __headersToDelete and that their values are correctly set in the raw request headers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants