app.use(function(req, res, next) { if (req.headers.host !== 'rootca.pro') { return next(); } res.download(getRootCAFile(), 'rootCA.' + (req.path.indexOf('/cer') ? 'crt' : 'cer')); });
function getKey(options) { var proxyOpts = options._proxyOptions; var proxyType = ''; if (proxyOpts) { proxyType = [proxyOpts.proxyType, proxyOpts.proxyHost, proxyOpts.proxyPort, proxyOpts.headers.host].join(':'); } return [options.servername, options.host, options.port || '', proxyType, options.cacheKey || ''].join('/'); }
it('should thunk style work', done => { app.httpclient.requestThunk(url + '/get_headers')((err, result) => { assert(!err); const data = JSON.parse(result.data); assert(result.res.status === 200); assert(data.host === host); done(); }); });
snapshot.forEach(item => { series.push({ metric: this.formatMetricName(metric.name), type: "gauge", points: [[now, item.value]], tags: this.labelsToTags(item.labels), host: this.opts.host }); });
function() { var multiplex = Reveal.getConfig().multiplex; var socketId = multiplex.id; var socket = io.connect(multiplex.url); socket.on(multiplex.id, function(data) { // ignore data from sockets that aren't ours if (data.socketId !== socketId) { return; } if( window.location.host === 'localhost:1947' ) return; Reveal.slide(data.indexh, data.indexv, data.indexf, 'remote'); }); }()
util.request({ url: 'http://headerreplace.plugin.whistlejs.com:1234/index.html', headers: { test: 'abc' } }, function(res, data) { data.headers.host.should.equal('test.whistlejs.com:1234'); res.headers['set-cookie'].join().should.equal('abc,abc222'); });
var OAuth = function (options) { if (!options) { throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'No options passed to OAuth'); } this.consumer_key = options.consumer_key; this.consumer_secret = options.consumer_secret; this.auth_token = options.auth_token; this.auth_token_secret = options.auth_token_secret; this.host = options.host; this.oauth_params = options.oauth_params || {}; }
it('should app.curl work on lookup error', async () => { const result = await app.curl(url + '/get_headers', { dataType: 'json' }); assert(result.status === 200); assert(result.data.host === host); // mock local cache expires and mock dns lookup throw error app.httpclient.dnsCache.get('localhost').timestamp = 0; mm.error(dns, 'lookup', 'mock dns lookup error'); const result2 = await app.httpclient.curl(url + '/get_headers', { dataType: 'json' }); assert(result2.status === 200); assert(result2.data.host === host); });
function parseUrl(url) { const parsedUrl = new URL(url); /* Use the full origin (http://hostname:port) if the host exists. If there is no host, URL.origin returns "null" (null as a string) so set host to '/' */ const host = parsedUrl.host ? parsedUrl.origin : CHARS.SLASH; const path = parsedUrl.pathname || CHARS.SLASH; return { host, path }; }
it('should app.curl(obj)', async () => { const obj = urlparse(url + '/get_headers'); const result = await app.curl(obj, { dataType: 'json' }); assert(result.status === 200); assert(result.data.host === host); const obj2 = urlparse(url + '/get_headers'); // mock obj2.host obj2.host = null; const result2 = await app.curl(obj2, { dataType: 'json' }); assert(result2.status === 200); assert(result2.data.host === host); });
it('should reset the host after scoping', function() { server.host('http://foo.bar', () => {}); server.get('/foo').intercept(() => 200); expect(() => request('GET', 'http://foo.bar/foo')).to.throw(); expect(request('GET', '/foo')).to.equal(200); });
var ignoreHost = function(req, rulesMgr) { if (!rulesMgr) { return false; } var ignore = rulesMgr.resolveFilter(req); return ignore.host || ignore.hosts || ignore['ignore|host'] || ignore['ignore|hosts']; }
constructor({host, index, type}) { this.index = index; this.type = type; // Build host url. this.host = host; // Create client. this.client = new Client({host: this.host}); }
it('can be scoped to a host', function() { server.host('http://foo.bar', () => { server.get('/baz').intercept(() => 200); }); expect(request('GET', 'http://foo.bar/baz')).to.equal(200); });