Skip to content

Commit 7ac705f

Browse files
Anton Egorovsindresorhus
authored andcommitted
fix Buffer.byteLength(req._header) throwing error (#490)
1 parent bd3315b commit 7ac705f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function requestAsEventEmitter(opts) {
204204
}
205205

206206
const lastUploaded = uploaded;
207-
const headersSize = Buffer.byteLength(req._header);
207+
const headersSize = req._header ? Buffer.byteLength(req._header) : 0;
208208
uploaded = socket.bytesWritten - headersSize;
209209

210210
// Prevent the known issue of `bytesWritten` being larger than body size

0 commit comments

Comments
 (0)