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

Fix http cache with authorized requests #347

Merged
merged 2 commits into from
Nov 16, 2018
Merged

Conversation

carlosms
Copy link
Contributor

@carlosms carlosms commented Nov 13, 2018

Fix #124.

The problem was that we were chaining RoundTrippers like this:
httpcache -> limit -> github Auth.
So the cache was getting requests that did not have any auth headers added yet, but when the responses got back from github, they did have those headers.
When comparing requests with the stored responses the headers did not match, and the cache was never used.

With this PR the RoundTrippers are now chained like this: limit -> github Auth -> httpcache.

client.BaseURL = githubURL
client.UploadURL = githubURL
return client
}

func newTestPool(s suite.Suite, repoURLs []string, githubURL *url.URL, cache *cache.ValidableCache) *ClientPool {
client := newClient(githubURL, cache)
func newTestPool(s suite.Suite, repoURLs []string, githubURL *url.URL, cache *cache.ValidableCache, auth bool) *ClientPool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line is 124 characters (lll)

If you have feedback about this comment, please, tell us.

Copy link
Contributor

@smacker smacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like that we moved cache transport creation out of the client and every caller must create it but I'm not sure how to do it better. So ok.

@carlosms
Copy link
Contributor Author

👍 I agree it would be better to have it in a common place. But everything I could think of was too complex for such a small thing and would make the code hard to follow.

client.BaseURL = githubURL
client.UploadURL = githubURL
return client
}

func newTestPool(s suite.Suite, repoURLs []string, githubURL *url.URL, cache *cache.ValidableCache) *ClientPool {
client := newClient(githubURL, cache)
func newTestPool(s suite.Suite, repoURLs []string, githubURL *url.URL, cache *cache.ValidableCache, auth bool) *ClientPool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line is 124 characters (lll)

If you have feedback about this comment, please, tell us.

@carlosms carlosms merged commit a66f8d7 into src-d:master Nov 16, 2018
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

Successfully merging this pull request may close these issues.

2 participants