Skip to content

Commit 844418c

Browse files
committed
http: Add noDelay to http.request() options.
Add the noDelay option to the http.request() options such that .setNoDelay() will be called once a socket is obtained. Add note about noDelay only applying to a TCP socket.
1 parent d6f1e39 commit 844418c

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

doc/api/http.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,9 @@ changes:
22132213
**Default:** 8192 (8KB).
22142214
* `method` {string} A string specifying the HTTP request method. **Default:**
22152215
`'GET'`.
2216+
* `noDelay` {boolean} A boolean with which to call [`socket.setNoDelay()`][]
2217+
when a socket connection is established. This only applies when the
2218+
underlying connection is a TCP socket.
22162219
* `path` {string} Request path. Should include query string if any.
22172220
E.G. `'/index.html?page=12'`. An exception is thrown when the request path
22182221
contains illegal characters. Currently, only spaces are rejected but that

lib/_http_client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ function ClientRequest(input, options, cb) {
164164

165165
this.socketPath = options.socketPath;
166166

167+
if (options.noDelay !== undefined)
168+
this._deferToConnect('setNoDelay', [options.noDelay]);
169+
167170
if (options.timeout !== undefined)
168171
this.timeout = getTimerDuration(options.timeout, 'timeout');
169172

0 commit comments

Comments
 (0)