@@ -14,7 +14,7 @@ const { FormData } = require('./formdata')
14
14
const { kState } = require ( './symbols' )
15
15
const { webidl } = require ( './webidl' )
16
16
const { Blob, File : NativeFile } = require ( 'buffer' )
17
- const { kBodyUsed } = require ( '../core/symbols' )
17
+ const { kBodyUsed, kHeadersList } = require ( '../core/symbols' )
18
18
const assert = require ( 'assert' )
19
19
const { isErrored } = require ( '../core/util' )
20
20
const { isUint8Array, isArrayBuffer } = require ( 'util/types' )
@@ -369,10 +369,12 @@ function bodyMixinMethods (instance) {
369
369
370
370
throwIfAborted ( this [ kState ] )
371
371
372
- const contentType = this . headers . get ( 'Content-Type' )
372
+ const contentType = this . headers [ kHeadersList ] . get ( 'content-type' , true )
373
+
374
+ const mimeType = contentType !== null ? parseMIMEType ( contentType ) : 'failure'
373
375
374
376
// If mimeType’s essence is "multipart/form-data", then:
375
- if ( / m u l t i p a r t \ /f o r m - d a t a / . test ( contentType ) ) {
377
+ if ( mimeType !== 'failure' && mimeType . essence === ' multipart/form-data' ) {
376
378
const headers = { }
377
379
for ( const [ key , value ] of this . headers ) headers [ key ] = value
378
380
@@ -430,7 +432,7 @@ function bodyMixinMethods (instance) {
430
432
await busboyResolve
431
433
432
434
return responseFormData
433
- } else if ( / a p p l i c a t i o n \ /x - w w w - f o r m - u r l e n c o d e d / . test ( contentType ) ) {
435
+ } else if ( mimeType !== 'failure' && mimeType . essence === ' application/x-www-form-urlencoded' ) {
434
436
// Otherwise, if mimeType’s essence is "application/x-www-form-urlencoded", then:
435
437
436
438
// 1. Let entries be the result of parsing bytes.
0 commit comments