2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

test: add coverage for content-type header casing (#10573)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Raashish Aggarwal
2026-03-29 22:53:38 +05:30
committed by GitHub
parent 3ec6858bd4
commit 7173706380
+10 -7
View File
@@ -2503,7 +2503,7 @@ describe('supports http with nodejs', () => {
}); });
describe('URLEncoded Form', () => { describe('URLEncoded Form', () => {
it('should post object data as url-encoded form if content-type is application/x-www-form-urlencoded', async () => { it('should post object data as url-encoded form regardless of content-type header casing', async () => {
const app = express(); const app = express();
const obj = { const obj = {
arr1: ['1', '2', '3'], arr1: ['1', '2', '3'],
@@ -2530,12 +2530,15 @@ describe('supports http with nodejs', () => {
); );
try { try {
const response = await axios.post(`http://localhost:${server.address().port}/`, obj, { for (const headerName of ['content-type', 'Content-Type']) {
headers: { const response = await axios.post(`http://localhost:${server.address().port}/`, obj, {
'content-type': 'application/x-www-form-urlencoded', headers: {
}, [headerName]: 'application/x-www-form-urlencoded',
}); },
assert.deepStrictEqual(response.data, obj); });
assert.deepStrictEqual(response.data, obj);
}
} finally { } finally {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
server.close((error) => { server.close((error) => {