Skip to content

Commit 3c46c03

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 ddfb22f commit 3c46c03

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
@@ -1496,6 +1496,34 @@ added: v10.1.0
14961496
The `message.aborted` property will be `true` if the request has
14971497
been aborted.
14981498

1499+
### message.complete
1500+
<!-- YAML
1501+
added: v0.3.0
1502+
-->
1503+
1504+
* {boolean}
1505+
1506+
The `message.complete` property will be `true` if a complete HTTP message has
1507+
been received and successfully parsed.
1508+
1509+
This property is particularly useful as a means of determining if a client or
1510+
server fully transmitted a message before a connection was terminated:
1511+
1512+
```js
1513+
const req = http.request({
1514+
host: '127.0.0.1',
1515+
port: 8080,
1516+
method: 'POST'
1517+
}, (res) => {
1518+
res.resume();
1519+
res.on('end', () => {
1520+
if (!res.complete)
1521+
console.error(
1522+
'The connection was terminated while the message was still being sent');
1523+
});
1524+
});
1525+
```
1526+
14991527
### message.destroy([error])
15001528
<!-- YAML
15011529
added: v0.3.0

0 commit comments

Comments
 (0)