Skip to content

Commit f0bbe9b

Browse files
jasnellMylesBorins
authored andcommitted
doc: add documentation for http.IncomingMessage$complete
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 8a86c5d commit f0bbe9b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/api/http.md

+28
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,34 @@ added: v8.13.0
14211421
The `message.aborted` property will be `true` if the request has
14221422
been aborted.
14231423

1424+
### message.complete
1425+
<!-- YAML
1426+
added: v0.3.0
1427+
-->
1428+
1429+
* {boolean}
1430+
1431+
The `message.complete` property will be `true` if a complete HTTP message has
1432+
been received and successfully parsed.
1433+
1434+
This property is particularly useful as a means of determining if a client or
1435+
server fully transmitted a message before a connection was terminated:
1436+
1437+
```js
1438+
const req = http.request({
1439+
host: '127.0.0.1',
1440+
port: 8080,
1441+
method: 'POST'
1442+
}, (res) => {
1443+
res.resume();
1444+
res.on('end', () => {
1445+
if (!res.complete)
1446+
console.error(
1447+
'The connection was terminated while the message was still being sent');
1448+
});
1449+
});
1450+
```
1451+
14241452
### message.destroy([error])
14251453
<!-- YAML
14261454
added: v0.3.0

0 commit comments

Comments
 (0)