Skip to content

Commit 6d76f85

Browse files
jasnellrvagg
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 3025f35 commit 6d76f85

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
@@ -1441,6 +1441,34 @@ added: v8.13.0
14411441
The `message.aborted` property will be `true` if the request has
14421442
been aborted.
14431443

1444+
### message.complete
1445+
<!-- YAML
1446+
added: v0.3.0
1447+
-->
1448+
1449+
* {boolean}
1450+
1451+
The `message.complete` property will be `true` if a complete HTTP message has
1452+
been received and successfully parsed.
1453+
1454+
This property is particularly useful as a means of determining if a client or
1455+
server fully transmitted a message before a connection was terminated:
1456+
1457+
```js
1458+
const req = http.request({
1459+
host: '127.0.0.1',
1460+
port: 8080,
1461+
method: 'POST'
1462+
}, (res) => {
1463+
res.resume();
1464+
res.on('end', () => {
1465+
if (!res.complete)
1466+
console.error(
1467+
'The connection was terminated while the message was still being sent');
1468+
});
1469+
});
1470+
```
1471+
14441472
### message.destroy([error])
14451473
<!-- YAML
14461474
added: v0.3.0

0 commit comments

Comments
 (0)