Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2505f67

Browse filesBrowse files
cjihrigtargos
authored andcommitted
http: support readable hwm in IncomingMessage
This commit causes http.IncomingMessage instances to set their readableHighWaterMark value the same value used in the underlying socket. PR-URL: #30135 Fixes: #30107 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 978946e commit 2505f67
Copy full SHA for 2505f67

File tree

Expand file treeCollapse file tree

3 files changed

+37
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+37
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,10 @@ the request body should be sent.
16671667
## Class: http.IncomingMessage
16681668
<!-- YAML
16691669
added: v0.1.17
1670+
changes:
1671+
- version: REPLACEME
1672+
pr-url: https://github.com/nodejs/node/pull/30135
1673+
description: The `readableHighWaterMark` value mirrors that of the socket.
16701674
-->
16711675

16721676
* Extends: {stream.Readable}
Collapse file

‎lib/_http_incoming.js‎

Copy file name to clipboardExpand all lines: lib/_http_incoming.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ function readStop(socket) {
3737

3838
/* Abstract base class for ServerRequest and ClientResponse. */
3939
function IncomingMessage(socket) {
40-
Stream.Readable.call(this);
40+
let streamOptions;
41+
42+
if (socket) {
43+
streamOptions = {
44+
highWaterMark: socket.readableHighWaterMark
45+
};
46+
}
47+
48+
Stream.Readable.call(this, streamOptions);
4149

4250
this._readableState.readingMore = true;
4351

Collapse file
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const http = require('http');
5+
const net = require('net');
6+
const readableHighWaterMark = 1024;
7+
const server = http.createServer((req, res) => { res.end(); });
8+
9+
server.listen(0, common.mustCall(() => {
10+
const req = http.request({
11+
port: server.address().port,
12+
createConnection(options) {
13+
options.readableHighWaterMark = readableHighWaterMark;
14+
return net.createConnection(options);
15+
}
16+
}, common.mustCall((res) => {
17+
assert.strictEqual(res.socket, req.socket);
18+
assert.strictEqual(res.socket.readableHighWaterMark, readableHighWaterMark);
19+
assert.strictEqual(res.readableHighWaterMark, readableHighWaterMark);
20+
server.close();
21+
}));
22+
23+
req.end();
24+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.