fix: allow user to delete default bruno headers in pre-request (#7331)

* fix: allow user to delete default bruno headers

* fix: resolved comments

---------

Co-authored-by: shubh-bruno <shubh-bruno@shubh-bruno.local>
This commit is contained in:
shubh-bruno
2026-03-03 14:35:54 +05:30
committed by GitHub
parent bba0e97435
commit ca0412b58b
5 changed files with 219 additions and 29 deletions

View File

@@ -126,10 +126,7 @@ class BrunoRequest {
}
deleteHeaders(headers) {
headers.forEach((name) => {
delete this.headers[name];
delete this.req.headers[name];
});
headers.forEach((name) => this.deleteHeader(name));
}
getHeader(name) {
@@ -144,6 +141,18 @@ class BrunoRequest {
deleteHeader(name) {
delete this.headers[name];
delete this.req.headers[name];
/**
Store header name to be applied in the axios request interceptor.
Default headers (user-agent, accept, accept-encoding, etc.) are added after
the pre-request script runs, so we track them here and delete them later.
*/
if (!this.req.__headersToDelete) {
this.req.__headersToDelete = [];
}
if (!this.req.__headersToDelete.includes(name)) {
this.req.__headersToDelete.push(name);
}
}
hasJSONContentType(headers) {