Git Product home page Git Product logo

Comments (14)

alex-training avatar alex-training commented on June 27, 2024

Have the same issue. Guys have you found any solution?

from angular-http-auth.

witoldsz avatar witoldsz commented on June 27, 2024

Hi guys, I am little of out scope right now, sorry for this, but may I suggest you look at the code of http-auth-interceptor to find answers for your questions? It's all just few lines of code in one file.

from angular-http-auth.

xeor avatar xeor commented on June 27, 2024

Hi

I have looked, but I'm not familiar with how AngularJS deals with all this internally, (and I'm still kinda new to js). Didn't find any clues first look. I can look again, but don't think I will get any further. Any hints for what it can be?

from angular-http-auth.

alex-training avatar alex-training commented on June 27, 2024

Hi guys!
I have looked at the code of http-auth-interceptor and I think that the problem is on
ng-file-upload side

https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
If i comment out lines 66-83 it fixes the issue

from angular-http-auth.

alex-training avatar alex-training commented on June 27, 2024

IMHO here is buggy code

if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
  window.XMLHttpRequest.prototype.setRequestHeader = (function (orig) {
    return function (header, value) {
      if (header === '__setXHR_') {
        var val = value(this);
        // fix for angular < 1.2.0
        if (val instanceof Function) {
          val(this);
        }
      } else {
        orig.apply(this, arguments);
      }
    };
  })(window.XMLHttpRequest.prototype.setRequestHeader);
}

and

config.headers.__setXHR_ = function () {
  return function (xhr) {
    if (!xhr) return;
    config.__XHR = xhr;
    if (config.xhrFn) config.xhrFn(xhr);
    xhr.upload.addEventListener('progress', function (e) {
      e.config = config;
      notifyProgress(getNotifyEvent(e));
    }, false);
    //fix for firefox not firing upload progress end, also IE8-9
    xhr.upload.addEventListener('load', function (e) {
      if (e.lengthComputable) {
        e.config = config;
        notifyProgress(getNotifyEvent(e));
      }
    }, false);
  };
};

Now i'm going to create new issue on ng-file-upload git

from angular-http-auth.

xeor avatar xeor commented on June 27, 2024

Nice find 👍

from angular-http-auth.

danialfarid avatar danialfarid commented on June 27, 2024

@alex-training that's how the plugin listen to the progress event if you remove those lines file progress feature will be removed too

from angular-http-auth.

danialfarid avatar danialfarid commented on June 27, 2024

If you guys can create a small jsfiddle showing the error I can debug it and find out where the issue is.
You can POST to this url to simulate 401 error: https://angular-file-upload-cors-srv.appspot.com/upload?errorCode=401&errorMessage=error

from angular-http-auth.

alex-training avatar alex-training commented on June 27, 2024

@danialfarid
Unfortunately I understand that the feature will be removed too...

OK, I will create jsfiddle project to reproduce this behavior

from angular-http-auth.

alex-training avatar alex-training commented on June 27, 2024

@danialfarid
@xeor
@witoldsz

Guys please have a look at jsfiddle

https://jsfiddle.net/alexedu/4na60fpd/

You can see all errors in browser console

from angular-http-auth.

xeor avatar xeor commented on June 27, 2024

Thanks @alex-training for making the jsfiddle. I have nothing to add, this is the one :)

from angular-http-auth.

danialfarid avatar danialfarid commented on June 27, 2024

This is fixed at ng-file-upload#8.0.4, you can close this issue now.

from angular-http-auth.

xeor avatar xeor commented on June 27, 2024

Very nice! Thank you @danialfarid for the quick fix!

from angular-http-auth.

alex-training avatar alex-training commented on June 27, 2024

Thank you @danialfarid

from angular-http-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.