Skip to content

Commit

Permalink
http: name anonymous functions in _http_outgoing
Browse files Browse the repository at this point in the history
Refs: #8913
PR-URL: #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>
  • Loading branch information
maasencioh authored and jasnell committed Oct 18, 2016
1 parent 5a2b714 commit 86c4a5c
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function utcDate() {
}
return dateCache;
}
utcDate._onTimeout = function() {
utcDate._onTimeout = function _onTimeout() {
dateCache = undefined;
};

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 + '"]');
Expand All @@ -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)');
}
Expand All @@ -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)');
}
Expand All @@ -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');
}
Expand All @@ -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');
};

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');
};
Expand All @@ -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;

Expand Down Expand Up @@ -688,7 +690,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) {
};


OutgoingMessage.prototype.flushHeaders = function() {
OutgoingMessage.prototype.flushHeaders = function flushHeaders() {
if (!this._header) {
this._implicitHeader();
}
Expand Down

0 comments on commit 86c4a5c

Please sign in to comment.