File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,10 @@ export class MultipartFormDataMatcher extends Serializable implements RequestMat
403
403
const parsedBody = multipart . parse ( await request . body . asDecodedBuffer ( ) , boundary [ 1 ] ) ;
404
404
405
405
return this . matchConditions . every ( ( condition ) => {
406
- const expectedContent = condition . content
407
- ? Buffer . from ( condition . content )
406
+ const expectedContent = typeof condition . content === 'string'
407
+ ? Buffer . from ( condition . content , "utf8" )
408
+ : condition . content
409
+ ? Buffer . from ( condition . content )
408
410
: undefined ;
409
411
410
412
return parsedBody . some ( ( part ) =>
Original file line number Diff line number Diff line change @@ -193,7 +193,10 @@ async function writeResponseFromCallback(
193
193
// RawBody takes priority if both are set (useful for backward compat) but if not then
194
194
// the body is automatically encoded to match the content-encoding header.
195
195
result . rawBody = await encodeBodyBuffer (
196
- Buffer . from ( result . body ) ,
196
+ // Separate string case mostly required due to TS type issues:
197
+ typeof result . body === 'string'
198
+ ? Buffer . from ( result . body , "utf8" )
199
+ : Buffer . from ( result . body ) ,
197
200
result . headers ?? { }
198
201
) ;
199
202
}
Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ export function getHttp2Body(req: http2.ClientHttp2Stream) {
296
296
297
297
const body : Buffer [ ] = [ ] ;
298
298
req . on ( 'data' , ( d : Buffer | string ) => {
299
- body . push ( Buffer . from ( d ) ) ;
299
+ body . push ( Buffer . from ( d as Buffer ) ) ;
300
300
} ) ;
301
301
req . on ( 'end' , ( ) => req . close ( ) ) ;
302
302
req . on ( 'close' , ( ) => resolve ( Buffer . concat ( body ) ) ) ;
You can’t perform that action at this time.
0 commit comments