File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 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
403403 const parsedBody = multipart . parse ( await request . body . asDecodedBuffer ( ) , boundary [ 1 ] ) ;
404404
405405 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 )
408410 : undefined ;
409411
410412 return parsedBody . some ( ( part ) =>
Original file line number Diff line number Diff line change @@ -193,7 +193,10 @@ async function writeResponseFromCallback(
193193 // RawBody takes priority if both are set (useful for backward compat) but if not then
194194 // the body is automatically encoded to match the content-encoding header.
195195 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 ) ,
197200 result . headers ?? { }
198201 ) ;
199202 }
Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ export function getHttp2Body(req: http2.ClientHttp2Stream) {
296296
297297 const body : Buffer [ ] = [ ] ;
298298 req . on ( 'data' , ( d : Buffer | string ) => {
299- body . push ( Buffer . from ( d ) ) ;
299+ body . push ( Buffer . from ( d as Buffer ) ) ;
300300 } ) ;
301301 req . on ( 'end' , ( ) => req . close ( ) ) ;
302302 req . on ( 'close' , ( ) => resolve ( Buffer . concat ( body ) ) ) ;
You can’t perform that action at this time.
0 commit comments