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

Modify request headers before httpBuffer.retryAll() #24

Closed
airtonix opened this issue May 19, 2013 · 2 comments
Closed

Modify request headers before httpBuffer.retryAll() #24

airtonix opened this issue May 19, 2013 · 2 comments

Comments

@airtonix
Copy link

https://github.com/witoldsz/angular-http-auth/blob/master/src/http-auth-interceptor.js#L23

After login and before replay of all buffered requests, I need to modify the headers so that they include a required Authorization header with username and apikey.

I'm new to angular, but would it be good enough to do something like :
https://github.com/edmenendez/django-angular-auth/blob/master/static/js/controllers.js#L27

@airtonix
Copy link
Author

The solution is to use the $http.post, $http.get, $http.put, $http.patch, $http.delete, shortcuts instead of $http({ method: "POST"}).

This way they use the common headers which you can update at anytime,

@laurelnaiad
Copy link

What, if anything, needs to happen such that buffered $http requests are retried with either the up-to-date default configuration, or with an override that is specific to the retries?

Right now it looks like the config is bundled in the retry buffer... would it be correct/useful to take what's in the retry buffer, merge the new $http defaults onto it, and then merge anything provided by the loginConfirmed function as an extra level of controlling those requests?

So, the default behavior would be:

  • take the buffered $http config for any request and apply the new (newly) current default $http config on top of that
  • using the buffered configs as the basis for the ultimately applicable config when these retries occur only impacts the bufferred requests... everything else proceeds with $http defaults, whatever they may be when subsequent requests are made
  • if, during the course of confirming the login, any changes should be applied to the bufferred requests, and such changes should not impact the longer-term behavior of $http, then the client specifies a config object when confirning the login to the service, such that it will override the config that would otherwise be used.

I think I should have written code to express that...

Basically, make sure that by default http-auth takes the combination of the fresh default $http config when it retries.

And for bonus points, let someone specify additional overrides to the defaults for purposes of only the retries.

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

2 participants