http: name anonymous functions in _http_outgoing

Refs: https://github.com/nodejs/node/issues/8913
PR-URL: https://github.com/nodejs/node/pull/9055
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
maasencioh 2016-10-12 15:48:40 +02:00 коммит произвёл James M Snell
Родитель 239ff06126
Коммит 2ccf601efe
1 изменённых файлов: 22 добавлений и 20 удалений

Просмотреть файл

@ -40,7 +40,7 @@ function utcDate() {
}
return dateCache;
}
utcDate._onTimeout = function() {
utcDate._onTimeout = function _onTimeout() {
dateCache = undefined;
};
@ -91,7 +91,7 @@ util.inherits(OutgoingMessage, Stream);
exports.OutgoingMessage = OutgoingMessage;
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
OutgoingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
if (callback) {
this.on('timeout', callback);
@ -111,7 +111,7 @@ OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
// It's possible that the socket will be destroyed, and removed from
// any messages, before ever calling this. In that case, just skip
// it, since something else is destroying this connection anyway.
OutgoingMessage.prototype.destroy = function(error) {
OutgoingMessage.prototype.destroy = function destroy(error) {
if (this.socket)
this.socket.destroy(error);
else
@ -122,7 +122,7 @@ OutgoingMessage.prototype.destroy = function(error) {
// This abstract either writing directly to the socket or buffering it.
OutgoingMessage.prototype._send = function(data, encoding, callback) {
OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
// This is a shameful hack to get the headers and first body chunk onto
// the same packet. Future versions of Node are going to take care of
// this at a lower level and in a more general way.
@ -145,7 +145,8 @@ OutgoingMessage.prototype._send = function(data, encoding, callback) {
};
OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
OutgoingMessage.prototype._writeRaw = _writeRaw;
function _writeRaw(data, encoding, callback) {
if (typeof encoding === 'function') {
callback = encoding;
encoding = null;
@ -176,10 +177,10 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
// buffer, as long as we're not destroyed.
return this._buffer(data, encoding, callback);
}
};
}
OutgoingMessage.prototype._buffer = function(data, encoding, callback) {
OutgoingMessage.prototype._buffer = function _buffer(data, encoding, callback) {
this.output.push(data);
this.outputEncodings.push(encoding);
this.outputCallbacks.push(callback);
@ -190,7 +191,8 @@ OutgoingMessage.prototype._buffer = function(data, encoding, callback) {
};
OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
OutgoingMessage.prototype._storeHeader = _storeHeader;
function _storeHeader(firstLine, headers) {
// firstLine in the case of request is: 'GET /index.html HTTP/1.1\r\n'
// in the case of response it is: 'HTTP/1.1 200 OK\r\n'
var state = {
@ -307,7 +309,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
// wait until the first body chunk, or close(), is sent to flush,
// UNLESS we're sending Expect: 100-continue.
if (state.sentExpect) this._send('');
};
}
function storeHeader(self, state, field, value) {
if (!common._checkIsHttpToken(field)) {
@ -346,7 +348,7 @@ function storeHeader(self, state, field, value) {
}
OutgoingMessage.prototype.setHeader = function(name, value) {
OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
if (!common._checkIsHttpToken(name))
throw new TypeError(
'Header name must be a valid HTTP Token ["' + name + '"]');
@ -369,7 +371,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) {
};
OutgoingMessage.prototype.getHeader = function(name) {
OutgoingMessage.prototype.getHeader = function getHeader(name) {
if (arguments.length < 1) {
throw new Error('"name" argument is required for getHeader(name)');
}
@ -381,7 +383,7 @@ OutgoingMessage.prototype.getHeader = function(name) {
};
OutgoingMessage.prototype.removeHeader = function(name) {
OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
if (arguments.length < 1) {
throw new Error('"name" argument is required for removeHeader(name)');
}
@ -404,7 +406,7 @@ OutgoingMessage.prototype.removeHeader = function(name) {
};
OutgoingMessage.prototype._renderHeaders = function() {
OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
if (this._header) {
throw new Error('Can\'t render headers after they are sent to the client');
}
@ -423,7 +425,7 @@ OutgoingMessage.prototype._renderHeaders = function() {
return headers;
};
OutgoingMessage.prototype._implicitHeader = function() {
OutgoingMessage.prototype._implicitHeader = function _implicitHeader() {
throw new Error('_implicitHeader() method is not implemented');
};
@ -434,7 +436,7 @@ Object.defineProperty(OutgoingMessage.prototype, 'headersSent', {
});
OutgoingMessage.prototype.write = function(chunk, encoding, callback) {
OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
if (this.finished) {
var err = new Error('write after end');
process.nextTick(writeAfterEndNT, this, err, callback);
@ -513,7 +515,7 @@ function escapeHeaderValue(value) {
}
OutgoingMessage.prototype.addTrailers = function(headers) {
OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
this._trailer = '';
var keys = Object.keys(headers);
var isArray = Array.isArray(headers);
@ -542,7 +544,7 @@ OutgoingMessage.prototype.addTrailers = function(headers) {
const crlf_buf = Buffer.from('\r\n');
OutgoingMessage.prototype.end = function(data, encoding, callback) {
OutgoingMessage.prototype.end = function end(data, encoding, callback) {
if (typeof data === 'function') {
callback = data;
data = null;
@ -618,7 +620,7 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
};
OutgoingMessage.prototype._finish = function() {
OutgoingMessage.prototype._finish = function _finish() {
assert(this.connection);
this.emit('prefinish');
};
@ -643,7 +645,7 @@ OutgoingMessage.prototype._finish = function() {
//
// This function, outgoingFlush(), is called by both the Server and Client
// to attempt to flush any pending messages out to the socket.
OutgoingMessage.prototype._flush = function() {
OutgoingMessage.prototype._flush = function _flush() {
var socket = this.socket;
var ret;
@ -688,7 +690,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) {
};
OutgoingMessage.prototype.flushHeaders = function() {
OutgoingMessage.prototype.flushHeaders = function flushHeaders() {
if (!this._header) {
this._implicitHeader();
}