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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {