mirror of https://github.com/lukechilds/got.git
Vsevolod Strukchinsky
9 years ago
16 changed files with 52 additions and 59 deletions
@ -1,42 +0,0 @@ |
|||
'use strict'; |
|||
var http = require('http'); |
|||
var https = require('https'); |
|||
var pify = require('pify'); |
|||
var getPort = require('get-port'); |
|||
var host = exports.host = 'localhost'; |
|||
|
|||
exports.createServer = function () { |
|||
return getPort().then(function (port) { |
|||
var s = http.createServer(function (req, resp) { |
|||
s.emit(req.url, req, resp); |
|||
}); |
|||
|
|||
s.host = host; |
|||
s.port = port; |
|||
s.url = 'http://' + host + ':' + port; |
|||
s.protocol = 'http'; |
|||
|
|||
s.listen = pify(s.listen, Promise); |
|||
s.close = pify(s.close, Promise); |
|||
|
|||
return s; |
|||
}); |
|||
}; |
|||
|
|||
exports.createSSLServer = function (opts) { |
|||
return getPort().then(function (port) { |
|||
var s = https.createServer(opts, function (req, resp) { |
|||
s.emit(req.url, req, resp); |
|||
}); |
|||
|
|||
s.host = host; |
|||
s.port = port; |
|||
s.url = 'https://' + host + ':' + port; |
|||
s.protocol = 'https'; |
|||
|
|||
s.listen = pify(s.listen, Promise); |
|||
s.close = pify(s.close, Promise); |
|||
|
|||
return s; |
|||
}); |
|||
}; |
@ -0,0 +1,38 @@ |
|||
'use strict'; |
|||
const http = require('http'); |
|||
const https = require('https'); |
|||
const pify = require('pify'); |
|||
const getPort = require('get-port'); |
|||
const host = exports.host = 'localhost'; |
|||
|
|||
exports.createServer = function () { |
|||
return getPort().then(port => { |
|||
const s = http.createServer((req, resp) => s.emit(req.url, req, resp)); |
|||
|
|||
s.host = host; |
|||
s.port = port; |
|||
s.url = `http://${host}:${port}`; |
|||
s.protocol = 'http'; |
|||
|
|||
s.listen = pify(s.listen, Promise); |
|||
s.close = pify(s.close, Promise); |
|||
|
|||
return s; |
|||
}); |
|||
}; |
|||
|
|||
exports.createSSLServer = function (opts) { |
|||
return getPort().then(port => { |
|||
const s = https.createServer(opts, (req, resp) => s.emit(req.url, req, resp)); |
|||
|
|||
s.host = host; |
|||
s.port = port; |
|||
s.url = `https://${host}:${port}`; |
|||
s.protocol = 'https'; |
|||
|
|||
s.listen = pify(s.listen, Promise); |
|||
s.close = pify(s.close, Promise); |
|||
|
|||
return s; |
|||
}); |
|||
}; |
Loading…
Reference in new issue