From 6d76f852a9b3c2648d393ac39ca8b2a33574e567 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Oct 2018 15:09:16 -0700 Subject: [PATCH] doc: add documentation for http.IncomingMessage$complete Fixes: https://github.com/nodejs/node/issues/8102 PR-URL: https://github.com/nodejs/node/pull/23914 Reviewed-By: Luigi Pinca Reviewed-By: Vse Mozhet Byt Reviewed-By: Trivikram Kamat --- doc/api/http.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 6adf88f09db6a2..8fea8ea343f84d 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1441,6 +1441,34 @@ added: v8.13.0 The `message.aborted` property will be `true` if the request has been aborted. +### message.complete + + +* {boolean} + +The `message.complete` property will be `true` if a complete HTTP message has +been received and successfully parsed. + +This property is particularly useful as a means of determining if a client or +server fully transmitted a message before a connection was terminated: + +```js +const req = http.request({ + host: '127.0.0.1', + port: 8080, + method: 'POST' +}, (res) => { + res.resume(); + res.on('end', () => { + if (!res.complete) + console.error( + 'The connection was terminated while the message was still being sent'); + }); +}); +``` + ### message.destroy([error])