Files
bruno/packages/bruno-tests/collection/echo/echo default request headers.bru
James b91f9ba5be fix: preserve axios default Accept header when setting User-Agent (#7820)
Assigning `defaults.headers.common = { 'User-Agent': ... }` replaced the
entire common headers object, nuking axios's built-in default:

  Accept: application/json, text/plain, */*

This caused servers relying on content-negotiation to receive requests
with no Accept header. Fix by extending the existing object with a
property assignment instead.

Add regression tests for both electron and CLI axios instances verifying
that Accept is preserved and User-Agent is set correctly.

Co-authored-by: Pragadesh-45 <temporaryg7904@gmail.com>
2026-05-05 21:38:12 +05:30

29 lines
817 B
Plaintext

meta {
name: echo default request headers
type: http
seq: 14
}
post {
url: {{echo-host}}
body: none
auth: none
}
tests {
test("sends Accept header with application/json by default", function() {
// The echo server reflects request headers back as response headers.
// Verifies that axios's default Accept header is not clobbered when
// setting User-Agent (regression for: defaults.headers.common object replacement).
const accept = res.getHeaders()["accept"];
expect(accept).to.be.a("string");
expect(accept).to.include("application/json");
});
test("sends User-Agent header with bruno-runtime prefix", function() {
const userAgent = res.getHeaders()["user-agent"];
expect(userAgent).to.be.a("string");
expect(userAgent).to.match(/^bruno-runtime\//);
});
}