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

addFromURL() Not Following Redirects #2314

Closed
leoherzog opened this issue Jul 30, 2019 · 2 comments
Closed

addFromURL() Not Following Redirects #2314

leoherzog opened this issue Jul 30, 2019 · 2 comments

Comments

@leoherzog
Copy link

leoherzog commented Jul 30, 2019

Hello!

I'm running this in NodeJS:

const ipfs = require('ipfs');
const node = new ipfs();
node.addFromURL("http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso", (error, result) => {
  if (error) {
    console.log(error.message);
  }
  console.log("Added " + result[0].path + " to IPFS - " + result[0].hash);
});

I get the hash almost right away, but it looks like js-ipfs is adding that HTML page to IPFS, not the ISO. I'm confused by this, because I thought that js-ipfs was supposed to follow redirects. If I wget that same URL, it 302 Redirects to a mirror. Help?

@alanshaw
Copy link
Member

alanshaw commented Aug 1, 2019

Visiting that URL in a browser returns a 200 and a HTML page, so there's probably some header that wget is sending that's causing isoredirect.centos.org to redirect. Either that or isoredirect.centos.org is doing some user agent sniffing. If it's the former then I'd appreciate a PR to fix it but if it's the latter then there's not anything we can do about it (since User-Agent is a restricted header in the browser that we can't change).

Do you have any time to look into this further?

@leoherzog
Copy link
Author

leoherzog commented Aug 1, 2019

Aha. Further investigation: If I request "http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso" with the user agent "Wget/", sure enough, I get redirected. I guess they're doing some sniffing. ¯\(ツ)

@alanshaw alanshaw closed this as completed Aug 1, 2019
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