http.createServer(function(req, res) { var fullUrl = /^http:/.test(req.url) ? req.url : 'http://' + req.headers.host + req.url; var options = parseUrl(fullUrl); delete options.hostname; options.host = '127.0.0.1'; options.method = req.method; options.headers = req.headers; var client = http.request(options, function(_res) { _res.pipe(res); }); req.pipe(client); })
function getOpenPort (callback) { http.createServer().listen(0, function () { const port = this.address().port this.close(function () { callback(null, port) }) }) }
constructor () { super() this[kServer] = http.createServer() this[kEngine] = Engine.attach(this[kServer], { path: '/airtap/msg' }) this[kContexts] = new Map() this[kEngine].on('connection', this[kOnConnection].bind(this)) enableDestroy(this[kServer]) }
function serverFactory(fastlyHandler, opts) { if (server) throw new Error('Factory called twice'); server = http.createServer((req, res) => { fastlyHandler(req, res); }); return server; }
http.createServer(function(req, res) { req.on('error', util.noop); res.on('error', util.noop); var body = ''; var decoder = new StringDecoder('utf8'); req.on('data', function(data) { body += decoder.write(data); }); req.on('end', function() { body += decoder.end(); res.end(JSON.stringify({ type: 'server', url: req.url, method: req.method, headers: req.headers, body: body }, null, '\t')); }); }).listen(config.serverPort, startTest);
this[kServer] = http.createServer()
function createServer (requestListener, serverListenCallback, binaryTypes) { const server = http.createServer(requestListener) server._socketPathSuffix = getRandomString() server._binaryTypes = binaryTypes ? binaryTypes.slice() : [] server.on('listening', () => { server._isListening = true if (serverListenCallback) serverListenCallback() }) server.on('close', () => { server._isListening = false }) .on('error', (error) => { /* istanbul ignore else */ if (error.code === 'EADDRINUSE') { console.warn(`WARNING: Attempting to listen on socket ${getSocketPath(server._socketPathSuffix)}, but it is already in use. This is likely as a result of a previous invocation error or timeout. Check the logs for the invocation(s) immediately prior to this for root cause, and consider increasing the timeout and/or cpu/memory allocation if this is purely as a result of a timeout. aws-serverless-express will restart the Node.js server listening on a new port and continue with this request.`) server._socketPathSuffix = getRandomString() return server.close(() => startServer(server)) } else { console.log('ERROR: server error') console.error(error) } }) return server }
/** * Initialize a new `TestAgent`. * * @param {Function|Server} app * @param {Object} options * @api public */ function TestAgent(app: any, options: any) { // @ts-ignore Legacy type issues if (!(this instanceof TestAgent)) return new TestAgent(app, options); if (typeof app === 'function') app = http.createServer(app); // eslint-disable-line no-param-reassign if (options) { this._ca = options.ca; this._key = options.key; this._cert = options.cert; } Agent.call(this); this.app = app; }
http.createServer((req, res) => { var realpath = './stream-98.flv'; console.log(123)
http.createServer((req, res) => { serverStatic(req, res) }).listen(3044)
static createServer() { Server.server = createServer(Server.app.callback()); return Server; }
test('connects to a server', async () => { const server = http.createServer((req, res) => { send200(res, 'hi') }) server.listen() const port = server.address()['port'] const api = ext.create({ baseURL: `http://127.0.0.1:${port}`, }) const response = await api.get('/') expect(response.data).toBe('hi') })
http.createServer(function(req, res) { if (req.url == "/") { fs.readFile("./paint.html", function(err, data) { res.end(data) }) } })
http.createServer((req, res) => { res.writeHead(200); res.end('Hello World'); process.exit(1); }).listen(3000);
static createServer() { Server.server = createServer(Server.app.callback()); return Server; }