Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($http): resolve cached requests with the proper config when hitting a cached promise #6534

Closed
wants to merge 1 commit into from

Conversation

mfield
Copy link
Contributor

@mfield mfield commented Mar 4, 2014

If an $http request is cached but not yet resolved, and a second request is made to the same
URL; be sure to resolve the second request's promise with the second request's config object.

The way I read the current docs on $http, the original behavior is not described, so
this does not introduce any backwards compatibility concerns.

My use case is to communicate between interceptors on either side of the same request using data stashed in the config object. Since the interceptors are initialized once by the injector I don't see a good way to store the data in a closure instead. This behavior seems more consistent anyway, since the non-cached and cached-and-resolved cases both work as expected.

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#6534)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@davidjnelson davidjnelson self-assigned this Mar 4, 2014
@davidjnelson
Copy link
Contributor

Thanks @mfield for the PR! @IgorMinar I'm not sure the best person to ping for $http, so I was hoping you could take a look, thanks!

@davidjnelson davidjnelson added this to the Backlog milestone Mar 4, 2014
@davidjnelson davidjnelson removed their assignment Mar 4, 2014
@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@mfield mfield added cla: no and removed cla: yes labels Mar 4, 2014
…ng a cached promise

If an $http request is cached but not yet resolved, and a second request is made to the same
URL; be sure to resolve the second request's promise with the second request's config object.

The way I read the current docs on $http, the original behavior is not described, so
this does not introduce any backwards compatibility concerns.
@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@mfield mfield added cla: yes and removed cla: no labels Mar 4, 2014
@morganrallen
Copy link

I came across this while trying to find out if there was a bug in $http when cache returns a promise (yes).
And while messing around with this patch it appears to half fix my problem. There is still a problem in the situation where the cache doesn't have the desired data. In this case the promise should be rejected and the http request should continue. That makes sense, right? I have a patch if so, or I totally missed something on how the cache uses promises.

@pkozlowski-opensource
Copy link
Member

@mfield thnx for your PR but we are going to merge #9030 instead as it works corectly with headers and merges cleanly. Please do send us other PRs though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants