How to use the superagent.head function in superagent

To help you get started, we’ve selected a few superagent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Flolagale / mailin / lib / mailin.js View on Github external
if (configuration.profile) {
        logger.info('Enable memory profiling');
        setInterval(function () {
            var memoryUsage = process.memoryUsage();
            var ram = memoryUsage.rss + memoryUsage.heapUsed;
            var million = 1000000;
            logger.info('Ram Usage: ' + ram / million + 'mb | rss: ' + memoryUsage.rss / million +
                'mb | heapTotal: ' + memoryUsage.heapTotal / million +
                'mb | heapUsed: ' + memoryUsage.heapUsed / million);
        }, 500);
    }

    /* Check the webhook validity. */
    if (!configuration.disableWebhook) {
        var url = configuration.webhook;
        request
            .head(url)
            .timeout(3000)
            .end(function (err, resp) {
                if (err || resp.statusCode !== 200) {
                    logger.warn('Webhook ' + configuration.webhook +
                        ' seems invalid or down. You may want to double check the webhook url.');
                } else {
                    logger.info('Webhook ' + configuration.webhook + ' is valid, up and running.');
                }
            });
    }

    function validateAddress(addressType, email, envelope) {
        return new Promise(function (resolve, reject) {
            if (configuration.disableDnsLookup) {
                return resolve();
github atlasbot / bot / src / commands / Configuration / feeds / add.js View on Github external
const channel = (new this.Atlas.structs.Fuzzy(msg.guild.channels, {
			keys: ['name', 'id', 'mention'],
		})).search(channelQuery);

		if (!channel) {
			return responder.error('feeds.add.noChannel').send();
		}

		// validating the target
		switch (type) {
			case 'reddit':
				target = this.Atlas.lib.utils.cleanSubName(target);
				// validating reddit subreddits
				try {
					// will throw if it doesn't exist
					await superagent.head(`https://www.reddit.com/r/${target}.json`)
						.set('User-Agent', this.Atlas.userAgent);
				} catch (e) {
					if (!e.response || !e.status || e.status < 200 || e.status >= 500) {
						throw e;
					}

					if (e.status === 404) {
						return responder.error('feeds.add.invalidSubreddit', target).send();
					}

					const { location } = e.response.headers;

					if (location) {
						const { pathname } = url.parse(location);
						if (pathname.startsWith('/subreddits/search')) {
							return responder.error('feeds.add.invalidSubreddit', target).send();
github kvker / Spider / pixiv_col / main.js View on Github external
function checkLinkStatus({ imgTitle, imgName, originImgUrl }, index) {
  request.head(originImgUrl)
    .set('cookie', config.cookie)
    .set('referer', config.referer)
    .end((err, res) => {
      // 那啥,缩略图跟实际大小图,后缀不一定一样,你可以自己浏览几张看看就知道了
      if(err) {
        let originImgUrlFix = originImgUrl.match(/\.\w+$/)[0]
        let png = '.png'
        let jpg = '.jpg'
        if(originImgUrlFix === png) {
          imgName = imgTitle + jpg
          originImgUrl = originImgUrl.replace(/\.\w+$/, jpg)
        } else {
          imgName = imgTitle + png
          originImgUrl = originImgUrl.replace(/\.\w+$/, png)
        }
      }
github vpdb / server / src / app / games / game.api.acl.spec.js View on Github external
it('should allow check for existing games', function(done) {
			request.head('/api/v1/games/mb').as('member').end(hlp.status(404, done));
		});
github mauimauer / portify / data / gmusic.js View on Github external
GoogleMusic.prototype.init = function(googleAuth, cb) {
	this.googleAuth = googleAuth;
	var me = this;
	if(this.sid == undefined) {
		this.sid = googleAuth.getSID();
	}
	if(this.auth == undefined) {
		this.auth = googleAuth.getAuthId();
	}

	request
		.head(this.baseUrl+this.basePath+'/listen')
		.set('Authorization', 'GoogleLogin auth=' + this.auth)
		.set('User-Agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')
		.set('Cookie','SID='+me.sid)
		.end(function(res){
			var sjsaidCookie = res.header['set-cookie'][0];
			var xtCookie = res.header['set-cookie'][1];

			if(res.header['update-client-auth']) {
				console.log("newauth: "+ res.header['update-client-auth']);
				me.auth = res.header['update-client-auth'];
			}

			if(res.header["set-cookie"]) {
				for(var i = 0; i < res.header["set-cookie"].length; i++) {
					if(res.header['set-cookie'][i].indexOf("xt=") != -1) {
github hotosm / osm-analytics / app / components / Legend / index.js View on Github external
updateLastModified(layerName) {
    request.head(settings['vt-source']+'/'+layerName+'/0/0/0.pbf').end((err, res) => {
      if (!err) this.setState({
        lastModified: res.headers['last-modified']
      })
    })
  }
github devspace / devspace / src / scripts / app.js View on Github external
checkUpdates = key => {
		let column = this.state.columns[key];
		let lastModified = this.state.columnsModified ? this.state.columnsModified[key] : 0;

		return request
			.head(getURL(column.type, column.payload, this.props.auth.github.username, 1))
			.use(this.throttle.plugin)
			.set('Authorization', 'token ' + this.props.auth.github.accessToken)
			.set('If-Modified-Since', lastModified)
			.end((error, response) => {
				if (response && response.status === 200) {
					this.setHasUpdates('appear', key);
				} else {
					this.setHasUpdates(undefined, key);
				}
			});
	}
github researchspace / researchspace / metaphacts-platform / web / src / main / api / http / index.ts View on Github external
export function head(url: string) {
  return request.head(getAbsoluteUrl(url));
}
github grommet / grommet / src / js / utils / Rest.js View on Github external
head (uri, params) {
    var op = request.head(uri).query(buildParams(params).join('&'));
    op.timeout(_timeout);
    op.set(_headers);
    return op;
  },