How to use the needle.head function in needle

To help you get started, we’ve selected a few needle 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 cheeaun / busrouter-sg / tasks / compare-publictransport-streetdirectory.js View on Github external
function(done){
						needle.head('http://www.streetdirectory.com/asia_travel/mappage/ajax_new/get_bus_service_route.php?no=' + service + '&d=1&longlat=1', function(err, res){
							var len = res.headers['content-length'];
							var exists = len == undefined; // Exists when there's NO content-length (chunked)
							done(null, exists);
						});
					}
				], function(err, results){
github jaruba / PowderWeb / server / utils / misc.js View on Github external
urlType: (url, cb, errCb) => {
		if (url.startsWith('magnet')) {
	      cb({ isTorrent: 1 })
	      return
	    }
	    needle.head(url, {
	      open_timeout: 10000,
	      follow_max: 5,
	      headers: {
	        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36',
	        'Referer': url
	      }
	    }, (err, resp) => {
	      if (err || !resp || !resp.headers) {
	        errCb(err && err.message ? err.message : 'Unknown Error Occurred')
	      } else {

	        if (resp.headers.connection && resp.headers.connection == 'close' && !resp.headers['content-type'] && !resp.headers.location) {
	          streams.isRedirectToMagnet(url, (isMagnet) => {
	            if (isMagnet) {
	              cb({ isTorrent: 1 })
	            } else {
github mediathekview / mediathekviewweb / server / src / utils.ts View on Github external
return new Promise>((resolve, reject) => {
    Needle.head(url, (error, response) => {
      if (error) {
        return reject(error);
      }

      if (response.statusCode != 200) {
        return reject(new Error(`StatusCode ${response.statusCode}: ${response.statusMessage}`));
      }

      const lastModified = response.headers['last-modified'] as string;
      if (lastModified != undefined) {
        var parsed = new Date(lastModified);
        return resolve(Math.floor(parsed.getTime() / 1000));
      } else {
        return resolve(null);
      }
    });
github mediathekview / mediathekviewweb / server / src / filmlist-importer / listing / http-file.ts View on Github external
this._fetch = new Promise((resolve, reject) => {
      Needle.head(this.url, (error, response) => {
        if (error) {
          return reject(error);
        }

        if (response.statusCode != 200) {
          return reject(new Error(`StatusCode ${response.statusCode}: ${response.statusMessage}`));
        }

        const lastModified = response.headers['last-modified'] as string;
        if (lastModified != undefined) {
          var parsed = new Date(lastModified);
          this._timestamp = Math.floor(parsed.getTime() / 1000);
        }

        const contentLength = response.headers['content-length'] as string;
        if (contentLength != undefined) {
github itchio / itch / appsrc / promised / needle.ts View on Github external
export function head (uri: string, options: any, callback: INeedleCallback): INeedleRequest {
  if (isOffline()) { return closeConnection(callback); }
  return needle.head(uri, withProxy(options), callback);
}

needle

The leanest and most handsome HTTP client in the Nodelands.

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis