mirror of https://github.com/lukechilds/got.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
664 B
32 lines
664 B
import http from 'http';
|
|
import https from 'https';
|
|
|
|
export const host = 'localhost';
|
|
export let port = 6767;
|
|
export let portSSL = 16167;
|
|
|
|
export const createServer = port2 => {
|
|
port = port2 || ++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';
|
|
|
|
return s;
|
|
};
|
|
|
|
export const createSSLServer = (portSSL2, opts) => {
|
|
portSSL = portSSL2 || ++portSSL;
|
|
|
|
const s = https.createServer(opts, (req, resp) => s.emit(req.url, req, resp));
|
|
|
|
s.host = host;
|
|
s.port = portSSL;
|
|
s.url = `https://${host}:${portSSL}`;
|
|
s.protocol = 'https';
|
|
|
|
return s;
|
|
};
|
|
|