Skip to content

Commit

Permalink
http: name anonymous functions in _http_client
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 19, 2016
1 parent 9099a43 commit ec17e76
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ exports.ClientRequest = ClientRequest;

ClientRequest.prototype.aborted = undefined;

ClientRequest.prototype._finish = function() {
ClientRequest.prototype._finish = function _finish() {
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
LTTNG_HTTP_CLIENT_REQUEST(this, this.connection);
COUNTER_HTTP_CLIENT_REQUEST();
OutgoingMessage.prototype._finish.call(this);
};

ClientRequest.prototype._implicitHeader = function() {
ClientRequest.prototype._implicitHeader = function _implicitHeader() {
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
this._renderHeaders());
};

ClientRequest.prototype.abort = function() {
ClientRequest.prototype.abort = function abort() {
if (this.aborted === undefined) {
process.nextTick(emitAbortNT, this);
}
Expand Down Expand Up @@ -567,7 +567,7 @@ function tickOnSocket(req, socket) {
req.emit('socket', socket);
}

ClientRequest.prototype.onSocket = function(socket) {
ClientRequest.prototype.onSocket = function onSocket(socket) {
process.nextTick(onSocketNT, this, socket);
};

Expand All @@ -580,7 +580,8 @@ function onSocketNT(req, socket) {
}
}

ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) {
ClientRequest.prototype._deferToConnect = _deferToConnect;
function _deferToConnect(method, arguments_, cb) {
// This function is for calls that need to happen once the socket is
// connected and writable. It's an important promisy thing for all the socket
// calls that happen either now (when a socket is assigned) or
Expand All @@ -596,7 +597,7 @@ ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) {
cb();
}

var onSocket = function() {
var onSocket = function onSocket() {
if (self.socket.writable) {
callSocketMethod();
} else {
Expand All @@ -609,9 +610,9 @@ ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) {
} else {
onSocket();
}
};
}

ClientRequest.prototype.setTimeout = function(msecs, callback) {
ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) {
if (callback) this.once('timeout', callback);

var self = this;
Expand Down Expand Up @@ -644,21 +645,21 @@ ClientRequest.prototype.setTimeout = function(msecs, callback) {
return this;
};

ClientRequest.prototype.setNoDelay = function() {
ClientRequest.prototype.setNoDelay = function setNoDelay() {
const argsLen = arguments.length;
const args = new Array(argsLen);
for (var i = 0; i < argsLen; i++)
args[i] = arguments[i];
this._deferToConnect('setNoDelay', args);
};
ClientRequest.prototype.setSocketKeepAlive = function() {
ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() {
const argsLen = arguments.length;
const args = new Array(argsLen);
for (var i = 0; i < argsLen; i++)
args[i] = arguments[i];
this._deferToConnect('setKeepAlive', args);
};

ClientRequest.prototype.clearTimeout = function(cb) {
ClientRequest.prototype.clearTimeout = function clearTimeout(cb) {
this.setTimeout(0, cb);
};

0 comments on commit ec17e76

Please sign in to comment.