Skip to content

Commit 24c6a02

Browse files
jasnelltargos
authored andcommitted
doc: add documentation for http.IncomingMessage$complete
Fixes: #8102 PR-URL: #23914 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 82ee6c3 commit 24c6a02

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
@@ -1500,6 +1500,34 @@ added: v10.1.0
15001500
The `message.aborted` property will be `true` if the request has
15011501
been aborted.
15021502

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

0 commit comments

Comments
 (0)