From 7623a9d41b53b1d8b290ab8dbaf7a73d5be0b53c Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Tue, 14 Feb 2017 19:02:46 +0100 Subject: [PATCH] Add UWS_HTTP environment variable By setting the UWS_HTTP environment variable to truthy one can now experiment with uws as the low level HTTP library (as opposed to core Node.js HTTP) --- lib/application.js | 2 +- lib/request.js | 2 +- lib/response.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/application.js b/lib/application.js index 0ee4def389..2b52e6d9ee 100644 --- a/lib/application.js +++ b/lib/application.js @@ -613,7 +613,7 @@ app.render = function render(name, options, callback) { */ app.listen = function listen() { - var server = http.createServer(this); + var server = process.env.UWS_HTTP ? require('uws').http.createServer(this) : http.createServer(this); return server.listen.apply(server, arguments); }; diff --git a/lib/request.js b/lib/request.js index 513c9bf3d4..600e65bf92 100644 --- a/lib/request.js +++ b/lib/request.js @@ -28,7 +28,7 @@ var proxyaddr = require('proxy-addr'); */ var req = exports = module.exports = { - __proto__: http.IncomingMessage.prototype + __proto__: process.env.UWS_HTTP ? require('uws').http.getRequestPrototype() : http.IncomingMessage.prototype }; /** diff --git a/lib/response.js b/lib/response.js index 6128f450a9..ca4292569d 100644 --- a/lib/response.js +++ b/lib/response.js @@ -38,7 +38,7 @@ var vary = require('vary'); */ var res = module.exports = { - __proto__: http.ServerResponse.prototype + __proto__: process.env.UWS_HTTP ? require('uws').http.getResponsePrototype() : http.ServerResponse.prototype }; /**