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

hope: XMLHttpRequest in deno #2191

Closed
runnerSnail opened this issue Apr 24, 2019 · 6 comments
Closed

hope: XMLHttpRequest in deno #2191

runnerSnail opened this issue Apr 24, 2019 · 6 comments

Comments

@runnerSnail
Copy link

No description provided.

@ry ry reopened this Apr 24, 2019
@MarkTiedemann
Copy link
Contributor

MarkTiedemann commented Jun 14, 2019

I believe XMLHttpRequest is needed for upload progress events.

Download progress can be measured with fetch already:

async function main() {
  let largeFileUrl = "http://download.inspire.net.nz/data/20MB.zip";
  let response = await fetch(largeFileUrl);
  let contentLength = parseInt(response.headers.get("Content-Length"));
  let readTotal = 0;
  let buffer = new Uint8Array(4096);
  let encoder = new TextEncoder();
  while (true) {
    let { nread, eof } = await response.body.read(buffer);
    readTotal += nread;
    let percent = ((readTotal / contentLength) * 100).toFixed(2);
    Deno.stdout.write(encoder.encode(`\r${percent}%`));
    if (eof) break;
  }
}

main();

@kitsonk
Copy link
Contributor

kitsonk commented Jun 15, 2019

I really think XMLHttpRequest is a big ole can of worms. It is a really old API with a load of crap to try to make it compatible with the browsers. IMO we really have to draw the line of "browser compatibility" somewhere.

The best thing is that is someone desired, to use the built in Deno bindings to create a polyfill in std and bring it into core if it actually worked well.

@ry
Copy link
Member

ry commented Jun 15, 2019

I agree with @kitsonk - it would be great if we didn't support XHR.

@MarkTiedemann I believe that "progress events" are available through fetch streaming?

@ry
Copy link
Member

ry commented Aug 13, 2020

Won’t implement

@Ciantic
Copy link

Ciantic commented Jun 15, 2022

I'm having problems with WASM files generated with emscripten because it uses in JS wrapper XMLHttpRequest.

emscripten-core/emscripten#6241

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

6 participants