Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll your own http client #15

Closed
dapplion opened this issue Nov 29, 2020 · 1 comment
Closed

Roll your own http client #15

dapplion opened this issue Nov 29, 2020 · 1 comment

Comments

@dapplion
Copy link
Contributor

dapplion commented Nov 29, 2020

To remove the dependency node-fetch consider writing an HTTP client to download a Github release asset to disk. Note it must

  • Follow N redirects
  • Handle networks errors
  • Handle fs errors
  • Have a timeout
  • Retry?

ChainSafe/lodestar#1783 (comment)

Proposed initial code by @mpetrunic

const https = require('https');
const fs = require('fs');

const file = fs.createWriteStream("./binding.node");
const request = https.get("<release url>", (response) => {
  if(response.statusCode == 302) {
     https.get(response.headers.location, (res) => {
        res.pipe(file);
     })
  } else {
     response.pipe(file);
  }
});
@matthewkeil
Copy link
Member

Closing. node-fetch removed by #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants