1.0.4 • Published 6 years ago

test-http-get v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

test-http-get

Test if a http request succeedes or not.

npm Node version Build Status JavaScript Style Guide

Use when you want to test if a resource exists and don't really care about the actual content of the resource. Will follow redirect responses.

Install

$ npm i test-http-get -S

Usage

Test if rvagg/node-levelup exists (GitHub should redirect to level/levelup):

const test = require('test-http-get')
test('https://github.com/rvagg/node-levelup', (err, exists) => {
  console.log(exists) // --> true
})

API

const test = require('test-http-get')

Returns a single function, see below.

test(url, cb)

Makes a http HEAD request on url.

  • If the status code is a redirect response, the request will be made again based on the returned Location header. Chainable redirect responses are handled up until a limit of 5 steps.
  • Calls back with cb(null, true) if the status code is < 300.
  • Calls back with cb(null, false) for status codes >= 400.
  • Calls back with cb(err) if no request could be made. Most likely an issue with the network or too many total redirect attempts.

License

MIT

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago