Comparing version 1.13.9 to 1.14.0
@@ -0,1 +1,4 @@ | ||
### 1.14.0 | ||
1. 添加 https 支持 | ||
### 1.13.9 | ||
@@ -2,0 +5,0 @@ 1. 调整 500 错误页显示 |
/* global process */ | ||
var http = require('http'); | ||
var https = require('https'); | ||
var fs = require('fs'); | ||
@@ -495,7 +496,7 @@ var util = require("util"); | ||
/** | ||
* 创建 http server 并处理 | ||
* 创建请求监听函数 | ||
**/ | ||
Server.prototype._createServer = function () { | ||
Server.prototype._createListener = function () { | ||
var self = this; | ||
self.httpServer = http.createServer(function (req, res) { | ||
return (function (req, res) { | ||
var context = new Context(self, req, res); | ||
@@ -530,2 +531,34 @@ //设置 server 头信息 | ||
}); | ||
}; | ||
/** | ||
* 生成 https 选项 | ||
**/ | ||
Server.prototype._getHttpsOptions = function (httpsConfigs) { | ||
var self = this; | ||
var httpsOptions = {}; | ||
if (httpsConfigs.key) { | ||
httpsOptions.key = fs.readFileSync(self.resolvePath(httpsConfigs.key)); | ||
} | ||
if (httpsConfigs.cert) { | ||
httpsOptions.cert = fs.readFileSync(self.resolvePath(httpsConfigs.cert)); | ||
} | ||
if (httpsConfigs.pfx) { | ||
httpsOptions.pfx = fs.readFileSync(self.resolvePath(httpsConfigs.pfx)); | ||
} | ||
return httpsOptions; | ||
}; | ||
/** | ||
* 创建 http server 并处理 | ||
**/ | ||
Server.prototype._createServer = function () { | ||
var self = this; | ||
if (!self.configs.https) { | ||
self.httpServer = http.createServer(self._createListener()); | ||
} else { | ||
var httpsOptions = self._getHttpsOptions(self.configs.https); | ||
self.httpServer = https.createServer(httpsOptions, self._createListener()); | ||
} | ||
//设定初始状态 | ||
self.httpServer.started = false; | ||
@@ -532,0 +565,0 @@ //close 事件 |
/** | ||
* Nokit - A Web development framework | ||
* @version v1.13.9 | ||
* @version v1.14.0 | ||
* @link http://nokit.org | ||
@@ -5,0 +5,0 @@ * @license MIT |
{ | ||
"name": "nokitjs", | ||
"rawName": "Nokit", | ||
"version": "1.13.9", | ||
"version": "1.14.0", | ||
"description": "A Web development framework", | ||
@@ -6,0 +6,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
353170
5009
7