From 71737063803fb0e26b2aa945d65155d66377f96d Mon Sep 17 00:00:00 2001 From: Raashish Aggarwal <94279692+raashish1601@users.noreply.github.com> Date: Sun, 29 Mar 2026 22:53:38 +0530 Subject: [PATCH] test: add coverage for content-type header casing (#10573) Co-authored-by: Jay --- tests/unit/adapters/http.test.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/unit/adapters/http.test.js b/tests/unit/adapters/http.test.js index c94d98a1..f77ff678 100644 --- a/tests/unit/adapters/http.test.js +++ b/tests/unit/adapters/http.test.js @@ -2503,7 +2503,7 @@ describe('supports http with nodejs', () => { }); 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 obj = { arr1: ['1', '2', '3'], @@ -2530,12 +2530,15 @@ describe('supports http with nodejs', () => { ); try { - const response = await axios.post(`http://localhost:${server.address().port}/`, obj, { - headers: { - 'content-type': 'application/x-www-form-urlencoded', - }, - }); - assert.deepStrictEqual(response.data, obj); + for (const headerName of ['content-type', 'Content-Type']) { + const response = await axios.post(`http://localhost:${server.address().port}/`, obj, { + headers: { + [headerName]: 'application/x-www-form-urlencoded', + }, + }); + + assert.deepStrictEqual(response.data, obj); + } } finally { await new Promise((resolve, reject) => { server.close((error) => {