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

[XMLHttpRequest] onprogress callback #3181

Closed
jamesfzhang opened this issue Oct 1, 2015 · 11 comments
Closed

[XMLHttpRequest] onprogress callback #3181

jamesfzhang opened this issue Oct 1, 2015 · 11 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@jamesfzhang
Copy link
Contributor

XMLHttpRequest currently doesn't support the onprogress callback for non-uploads. Any other way to estimate the progress of a GET request?

@mkonicek
Copy link
Contributor

mkonicek commented Oct 2, 2015

Good question! I don't think there is one currently.

@mkonicek
Copy link
Contributor

@facebook-github-bot answered

@facebook-github-bot
Copy link
Contributor

Closing this issue as @mkonicek says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Mar 16, 2016
@norbertsongin
Copy link

Is there any update on this?
According to this example xhr.upload.onprogress callback can be defined but the problem is that xhr.upload is left undefined.

@ryanlntn
Copy link
Contributor

I'm seeing the same thing. Not really sure how to work around it.

@ahanriat
Copy link
Contributor

Having the same issue, any update ?

@ryanlntn
Copy link
Contributor

ryanlntn commented May 24, 2016

@ahanriat There were a lot of updates to xhr in the 0.26 release. I'm in the process of updating right now and hoping that will fix it.

If that doesn't work you could try my workaround: #6986

@ahanriat
Copy link
Contributor

Thanks for the heads up @ryanlntn !! I'll try it :)

@GeoffreyPlitt
Copy link

I'm on RN=0.42 and using XHR with a Content-Length set before uploading begins. I'm seeing the progress events, but no bytesSent or length or anything else that I can use to compute a progress%. Anybody else have luck with this?

@butchmarshall
Copy link

I'm also seeing total, but no loaded progress on both RN=0.42 and RN=0.46.4

butchmarshall added a commit to butchmarshall/react-native that referenced this issue Oct 15, 2017
Gives loaded progress back to XMLHttpRequest
@butchmarshall
Copy link

I have a workaround for it at least.

Created a pull request here

In Libraries/Network/XMLHttpRequest.js

Change:


  __didReceiveIncrementalData(
    requestId: number,
    responseText: string,
    progress: number,
    total: number
  ) {
    if (requestId !== this._requestId) {
      return;
    }
    if (!this._response) {
      this._response = responseText;
    } else {
      this._response += responseText;
    }

    XMLHttpRequest._interceptor && XMLHttpRequest._interceptor.dataReceived(
      requestId,
      responseText);

    this.setReadyState(this.LOADING);
    this.__didReceiveDataProgress(requestId, progress, total);
  }

To


  __didReceiveIncrementalData(
    requestId: number,
    responseText: string,
    progress: number,
    total: number
  ) {
    if (requestId !== this._requestId) {
      return;
    }
    if (!this._response) {
      this._response = responseText;
    } else {
      this._response += responseText;
    }
    progress = this._response.length;

    XMLHttpRequest._interceptor && XMLHttpRequest._interceptor.dataReceived(
      requestId,
      responseText);

    this.setReadyState(this.LOADING);
    this.__didReceiveDataProgress(requestId, progress, total);
  }

butchmarshall added a commit to butchmarshall/react-native that referenced this issue Nov 15, 2017
Gives loaded progress back to XMLHttpRequest
@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants