witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

Interceptor buffers same request multiple times #9

Closed mzvonar closed 11 years ago

mzvonar commented 11 years ago

When same unauthenticated url is requested multiple times, interceptors stores this url multiple times.

This could be solved by changing the buffer to associative array as save request with url as key and then using for-in loop in retryAll() function. So if same url request is already in buffer it gets replaced with new request.

I'm not very experienced in JavaScript, nor AngularJS. So maybe this is not a good idea for some reason. But I can't see any problem so far. What do you think?

witoldsz commented 11 years ago

The URL can be same, but content can change. Also, there is a question: what to do with old requests replaced by new ones? Each request has some callback chain (functions attached to promises). Should we reject the promises of those requests?

This is why I have decided to store and eventually retry every request.

mzvonar commented 11 years ago

oh, ok. thanks for explaining