Skip to content

Commit ffa5c9e

Browse files
maasenciohjasnell
authored andcommitted
http: name anonymous functions in _http_outgoing
Refs: #8913 PR-URL: #9055 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent fa035ad commit ffa5c9e

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

lib/_http_outgoing.js

+22-20
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function utcDate() {
4040
}
4141
return dateCache;
4242
}
43-
utcDate._onTimeout = function() {
43+
utcDate._onTimeout = function _onTimeout() {
4444
dateCache = undefined;
4545
};
4646

@@ -91,7 +91,7 @@ util.inherits(OutgoingMessage, Stream);
9191
exports.OutgoingMessage = OutgoingMessage;
9292

9393

94-
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
94+
OutgoingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
9595

9696
if (callback) {
9797
this.on('timeout', callback);
@@ -111,7 +111,7 @@ OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
111111
// It's possible that the socket will be destroyed, and removed from
112112
// any messages, before ever calling this. In that case, just skip
113113
// it, since something else is destroying this connection anyway.
114-
OutgoingMessage.prototype.destroy = function(error) {
114+
OutgoingMessage.prototype.destroy = function destroy(error) {
115115
if (this.socket)
116116
this.socket.destroy(error);
117117
else
@@ -122,7 +122,7 @@ OutgoingMessage.prototype.destroy = function(error) {
122122

123123

124124
// This abstract either writing directly to the socket or buffering it.
125-
OutgoingMessage.prototype._send = function(data, encoding, callback) {
125+
OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
126126
// This is a shameful hack to get the headers and first body chunk onto
127127
// the same packet. Future versions of Node are going to take care of
128128
// this at a lower level and in a more general way.
@@ -145,7 +145,8 @@ OutgoingMessage.prototype._send = function(data, encoding, callback) {
145145
};
146146

147147

148-
OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
148+
OutgoingMessage.prototype._writeRaw = _writeRaw;
149+
function _writeRaw(data, encoding, callback) {
149150
if (typeof encoding === 'function') {
150151
callback = encoding;
151152
encoding = null;
@@ -176,10 +177,10 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
176177
// buffer, as long as we're not destroyed.
177178
return this._buffer(data, encoding, callback);
178179
}
179-
};
180+
}
180181

181182

182-
OutgoingMessage.prototype._buffer = function(data, encoding, callback) {
183+
OutgoingMessage.prototype._buffer = function _buffer(data, encoding, callback) {
183184
this.output.push(data);
184185
this.outputEncodings.push(encoding);
185186
this.outputCallbacks.push(callback);
@@ -190,7 +191,8 @@ OutgoingMessage.prototype._buffer = function(data, encoding, callback) {
190191
};
191192

192193

193-
OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
194+
OutgoingMessage.prototype._storeHeader = _storeHeader;
195+
function _storeHeader(firstLine, headers) {
194196
// firstLine in the case of request is: 'GET /index.html HTTP/1.1\r\n'
195197
// in the case of response it is: 'HTTP/1.1 200 OK\r\n'
196198
var state = {
@@ -307,7 +309,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
307309
// wait until the first body chunk, or close(), is sent to flush,
308310
// UNLESS we're sending Expect: 100-continue.
309311
if (state.sentExpect) this._send('');
310-
};
312+
}
311313

312314
function storeHeader(self, state, field, value) {
313315
if (!common._checkIsHttpToken(field)) {
@@ -346,7 +348,7 @@ function storeHeader(self, state, field, value) {
346348
}
347349

348350

349-
OutgoingMessage.prototype.setHeader = function(name, value) {
351+
OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
350352
if (!common._checkIsHttpToken(name))
351353
throw new TypeError(
352354
'Header name must be a valid HTTP Token ["' + name + '"]');
@@ -369,7 +371,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) {
369371
};
370372

371373

372-
OutgoingMessage.prototype.getHeader = function(name) {
374+
OutgoingMessage.prototype.getHeader = function getHeader(name) {
373375
if (arguments.length < 1) {
374376
throw new Error('"name" argument is required for getHeader(name)');
375377
}
@@ -381,7 +383,7 @@ OutgoingMessage.prototype.getHeader = function(name) {
381383
};
382384

383385

384-
OutgoingMessage.prototype.removeHeader = function(name) {
386+
OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
385387
if (arguments.length < 1) {
386388
throw new Error('"name" argument is required for removeHeader(name)');
387389
}
@@ -404,7 +406,7 @@ OutgoingMessage.prototype.removeHeader = function(name) {
404406
};
405407

406408

407-
OutgoingMessage.prototype._renderHeaders = function() {
409+
OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
408410
if (this._header) {
409411
throw new Error('Can\'t render headers after they are sent to the client');
410412
}
@@ -423,7 +425,7 @@ OutgoingMessage.prototype._renderHeaders = function() {
423425
return headers;
424426
};
425427

426-
OutgoingMessage.prototype._implicitHeader = function() {
428+
OutgoingMessage.prototype._implicitHeader = function _implicitHeader() {
427429
throw new Error('_implicitHeader() method is not implemented');
428430
};
429431

@@ -434,7 +436,7 @@ Object.defineProperty(OutgoingMessage.prototype, 'headersSent', {
434436
});
435437

436438

437-
OutgoingMessage.prototype.write = function(chunk, encoding, callback) {
439+
OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
438440
if (this.finished) {
439441
var err = new Error('write after end');
440442
process.nextTick(writeAfterEndNT, this, err, callback);
@@ -513,7 +515,7 @@ function escapeHeaderValue(value) {
513515
}
514516

515517

516-
OutgoingMessage.prototype.addTrailers = function(headers) {
518+
OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
517519
this._trailer = '';
518520
var keys = Object.keys(headers);
519521
var isArray = Array.isArray(headers);
@@ -542,7 +544,7 @@ OutgoingMessage.prototype.addTrailers = function(headers) {
542544
const crlf_buf = Buffer.from('\r\n');
543545

544546

545-
OutgoingMessage.prototype.end = function(data, encoding, callback) {
547+
OutgoingMessage.prototype.end = function end(data, encoding, callback) {
546548
if (typeof data === 'function') {
547549
callback = data;
548550
data = null;
@@ -618,7 +620,7 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
618620
};
619621

620622

621-
OutgoingMessage.prototype._finish = function() {
623+
OutgoingMessage.prototype._finish = function _finish() {
622624
assert(this.connection);
623625
this.emit('prefinish');
624626
};
@@ -643,7 +645,7 @@ OutgoingMessage.prototype._finish = function() {
643645
//
644646
// This function, outgoingFlush(), is called by both the Server and Client
645647
// to attempt to flush any pending messages out to the socket.
646-
OutgoingMessage.prototype._flush = function() {
648+
OutgoingMessage.prototype._flush = function _flush() {
647649
var socket = this.socket;
648650
var ret;
649651

@@ -688,7 +690,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) {
688690
};
689691

690692

691-
OutgoingMessage.prototype.flushHeaders = function() {
693+
OutgoingMessage.prototype.flushHeaders = function flushHeaders() {
692694
if (!this._header) {
693695
this._implicitHeader();
694696
}

0 commit comments

Comments
 (0)