http: Use OOP for OutgoingMessage._finish
Sniffing instanceof a child class in the parent class's method is Doing It Wrong.
This commit is contained in:
parent
49519f1217
commit
831de7cbb9
@ -133,6 +133,12 @@ util.inherits(ClientRequest, OutgoingMessage);
|
||||
|
||||
exports.ClientRequest = ClientRequest;
|
||||
|
||||
ClientRequest.prototype._finish = function() {
|
||||
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
|
||||
COUNTER_HTTP_CLIENT_REQUEST();
|
||||
OutgoingMessage.prototype._finish.call(this);
|
||||
};
|
||||
|
||||
ClientRequest.prototype._implicitHeader = function() {
|
||||
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
|
||||
this._renderHeaders());
|
||||
|
@ -515,25 +515,8 @@ OutgoingMessage.prototype.end = function(data, encoding) {
|
||||
};
|
||||
|
||||
|
||||
var ServerResponse, ClientRequest;
|
||||
|
||||
OutgoingMessage.prototype._finish = function() {
|
||||
assert(this.connection);
|
||||
|
||||
if (!ServerResponse)
|
||||
ServerResponse = require('_http_server').ServerResponse;
|
||||
|
||||
if (!ClientRequest)
|
||||
ClientRequest = require('_http_client').ClientRequest;
|
||||
|
||||
if (this instanceof ServerResponse) {
|
||||
DTRACE_HTTP_SERVER_RESPONSE(this.connection);
|
||||
COUNTER_HTTP_SERVER_RESPONSE();
|
||||
} else {
|
||||
assert(this instanceof ClientRequest);
|
||||
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
|
||||
COUNTER_HTTP_CLIENT_REQUEST();
|
||||
}
|
||||
this.emit('finish');
|
||||
};
|
||||
|
||||
|
@ -111,6 +111,13 @@ function ServerResponse(req) {
|
||||
}
|
||||
util.inherits(ServerResponse, OutgoingMessage);
|
||||
|
||||
ServerResponse.prototype._finish = function() {
|
||||
DTRACE_HTTP_SERVER_RESPONSE(this.connection);
|
||||
COUNTER_HTTP_SERVER_RESPONSE();
|
||||
OutgoingMessage.prototype._finish.call(this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports.ServerResponse = ServerResponse;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user