Skip to content

Commit 893239b

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 c54d3d9 commit 893239b

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
@@ -1516,6 +1516,34 @@ added: v10.1.0
15161516
The `message.aborted` property will be `true` if the request has
15171517
been aborted.
15181518

1519+
### message.complete
1520+
<!-- YAML
1521+
added: v0.3.0
1522+
-->
1523+
1524+
* {boolean}
1525+
1526+
The `message.complete` property will be `true` if a complete HTTP message has
1527+
been received and successfully parsed.
1528+
1529+
This property is particularly useful as a means of determining if a client or
1530+
server fully transmitted a message before a connection was terminated:
1531+
1532+
```js
1533+
const req = http.request({
1534+
host: '127.0.0.1',
1535+
port: 8080,
1536+
method: 'POST'
1537+
}, (res) => {
1538+
res.resume();
1539+
res.on('end', () => {
1540+
if (!res.complete)
1541+
console.error(
1542+
'The connection was terminated while the message was still being sent');
1543+
});
1544+
});
1545+
```
1546+
15191547
### message.destroy([error])
15201548
<!-- YAML
15211549
added: v0.3.0

0 commit comments

Comments
 (0)