function startStaticServer(port) { const fileServer = new statics.Server(`${__dirname}/data`); http.Server((req, res) => { req.addListener('end', () => { fileServer.serve(req, res); }).resume(); }).listen(port); }
function get(options, noJSON = false) { return new Promise((resolve, reject) => { https .get(options, makeCallback(resolve, reject, noJSON)) .on('error', reject); }); }
http.request(options, (res) => { console.info('STATUS: ' + res.statusCode); process.exitCode = (res.statusCode === 200) ? 0 : 1; process.exit(); })
app.ready().then(() => { console.log('app(%s) ready', app.config.baseDir); const server = http.createServer(app.callback()); // emit server event just like egg-cluster does // https://github.com/eggjs/egg-cluster/blob/master/lib/app_worker.js#L52 app.emit('server', server); server.listen(7001, () => { console.log('Server started at 7001'); }); });
// Initializes the server and mounts it in the generated build directory. http.createServer((req, res) => { // If we are accessing the root, it should be redirected to the default language, // We shouldn't get a 404 page. if (req.url === '/') { req.url = `/${mainLocale}` } mount(req, res) }).listen(port, () => { console.log(`\x1B[32mServer running at http://localhost:${port}/${mainLocale}/\x1B[39m`) })
describe('gae_flex_redislabs_memcache', () => { it('should be listening', async () => { const server = require('../app.js'); const isOpen = await waitPort({port: PORT}); expect(isOpen).to.be.true; server.close(); }); });
http.createServer(function (req, res) { var url = URL.parse(req.url); res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(fs.readFileSync(__dirname + url.pathname)); })
https.get(url, function(response) { if (response.statusCode !== 200) reject(new Error(`HTTP error ${response.statusCode}`)); response.pipe(file); file.on('finish', function() { // file.close(); resolve(); }); }).on('error', (error) => { reject(error); });
const downloadFileFromURI = uri => { return new Promise((res, rej) => { http.get(uri, response => { response.setDefaultEncoding('base64'); let body = `data:${response.headers['content-type']};base64,`; response.on('data', data => body += data); response.on('end', () => res(body)); }).on('error', e => { rej(`Error downloading file from ${uri}: ${e.message}`); }); }); }
function get(options, noJSON = false) { return new Promise((resolve, reject) => { https.get(options, makeCallback(resolve, reject, noJSON)).on('error', reject); }); }