Skip to content

Commit

Permalink
feat: use buffer length when available
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytelife26 committed Apr 12, 2021
1 parent 57bce8c commit 50c4ead
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/PetitioResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export class PetitioResponse {
/**
* This takes the data chunks and creates a Buffer, and it sets
* that buffer as the body.
* @param {*} chunk The chunk of data to append to the body.
* @param {*} chunks The body to set for the response.
* @return {*} In place operation with no return.
*/
public _addBody(chunk: Buffer[] | Uint8Array[]) {
this.body = Buffer.concat(chunk);
public _addBody(chunks: Buffer[] | Uint8Array[]) {
const length = this.headers["content-length"];
this.body = Buffer.concat(chunks, length ? Number(length) : undefined);
}

/**
Expand Down

0 comments on commit 50c4ead

Please sign in to comment.