witoldsz / angular-http-auth

MIT License
2.37k stars 416 forks source link

override common default headers for requests #60

Closed saturation closed 7 years ago

saturation commented 10 years ago

retry attempt now includes common default headers

saturation commented 10 years ago

method specific defaults are still missing thou

witoldsz commented 10 years ago

I am not sure this is a good idea, because default headers are just a defaults. If someone prepare a HTTP request with some specific settings, different from defaults, then the retry would override them.

I was thinking, maybe that would be good to apply defaults only to the fields which are missing in the configuration object of retry request?

saturation commented 10 years ago

thank you for reply.

Why do you think that is not a good idea? What are the downsides? No offense meant, just plain curious.

Like in my case I have my auth token in my default headers, so every request includes it by default.. So basically my workflow is: request -> 401 http-auth:loginform -> 200OK:token insert token to headers reply requests-> 200OK

What would be an alternative way to achieve this? Apparently there is a way to pass http-config as second parameter in loginConfirmed-method, but the documentation lacks

Also there are some functional changes between angular versions with http-auth according to the comments from here: http://witoldsz.github.io/angular-http-auth/ This change should fix their problems, I think?

You are using cookies to get around with this, am I correct?

witoldsz commented 10 years ago

Well, my point was that your change always overrides all the headers of request to be retried. It will work in your case, because you just add new header and everything else is the same, but if someone prepares a request with some headers different than the default ones, then your change will override them and break stuff.

The documentation in README.md was updated, updateConfigFunc parameter should work for you. Does it?

witoldsz commented 7 years ago

Fixed long time ago :)