File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ export function getBodyEncoding (req: CyHttpMessages.IncomingRequest): BodyEncod
251
251
if ( contentType . includes ( 'charset=utf-8' ) || contentType . includes ( 'charset="utf-8"' ) ) {
252
252
return 'utf8'
253
253
}
254
+
255
+ if ( contentType . includes ( 'multipart/form-data' ) ) {
256
+ return 'binary'
257
+ }
254
258
}
255
259
256
260
// with fallback to inspecting the buffer using
Original file line number Diff line number Diff line change @@ -69,5 +69,19 @@ describe('net-stubbing util', () => {
69
69
70
70
expect ( getBodyEncoding ( req ) , 'image' ) . to . equal ( 'binary' )
71
71
} )
72
+
73
+ it ( 'returns binary for form-data bodies' , ( ) => {
74
+ const formDataRequest = {
75
+ body : Buffer . from ( 'hello world' ) ,
76
+ headers : {
77
+ 'content-type' : 'multipart/form-data' ,
78
+ } ,
79
+ method : 'POST' ,
80
+ url : 'somewhere' ,
81
+ httpVersion : '1.1' ,
82
+ }
83
+
84
+ expect ( getBodyEncoding ( formDataRequest ) ) . to . equal ( 'binary' )
85
+ } )
72
86
} )
73
87
} )
You can’t perform that action at this time.
0 commit comments