mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-26 22:25:40 +00:00
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>
29 lines
817 B
Plaintext
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\//);
|
|
});
|
|
}
|