How to use the http-call.HTTP.stream function in http-call

To help you get started, we’ve selected a few http-call 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 jdxcode / npm-register / lib / npm.js View on Github external
function getTarball (name, filename) {
  return HTTP.stream(`${config.uplink.href}${name}/-/${filename}`, getRequestOpts())
}
github heroku / cli / packages / container-registry-v5 / lib / streamer.js View on Github external
async function call (url, out, retries) {
  try {
    let {response} = await http.stream(url)
    response.on('data', function (d) {
      out.write(d)
    })
    return await new Promise(function (resolve, reject) {
      response.on('error', reject)
      response.on('end', resolve)
    })
  } catch (err) {
    if (err.statusCode === 404 && retries <= maxRetries) {
      return new Promise(function (resolve, reject) {
        setTimeout(function () {
          call(url, out, retries + 1).then(resolve, reject)
        }, 1000)
      })
    }
    throw err

http-call

make http requests

ISC
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis