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

fetch doesn't follow redirects #2513

Closed
bartlomieju opened this issue Jun 13, 2019 · 3 comments · Fixed by #2561
Closed

fetch doesn't follow redirects #2513

bartlomieju opened this issue Jun 13, 2019 · 3 comments · Fixed by #2561

Comments

@bartlomieju
Copy link
Member

Currently fetch doesn't support redirects - eg:

// current behavior
const response = await fetch("https://deno.land/std/colors/mod.ts")
response.status // 302
response.redirected // false
await Deno.readAll(response.body) // Uint8Array [] - empty!

// expected behavior
const response = await fetch("https://deno.land/std/colors/mod.ts")
response.status // 200
response.redirected // true
await Deno.readAll(response.body) // Uint8Array [...snip...] - should be filled with data

I did quick research and it seems that hyper client doesn't support redirects. I found this extension: https://github.com/srijs/rust-follow-redirects, but it's not very popular so I guess we'll need to handle that ourselves.

This feature is needed for installer denoland/std#471.

@Fenzland
Copy link
Contributor

As I see, check response.status and refetch manually is better than auto follow.

@bartlomieju
Copy link
Member Author

My bad - of course you can configure fetch to either follow redirects or not with fetch(url, {redirect: "follow"}); - but still Deno does not support this option now.

@TonyLianLong
Copy link
Contributor

The redirected is unimplemented as in https://github.com/denoland/deno/blob/master/js/fetch.ts#L246. I can have a try at implementing this these two weeks when I'm free. This is a huge workload since redirected depends on unimplemented feature such as type and implementing redirected also requires the implementation of these features.

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

Successfully merging a pull request may close this issue.

3 participants