-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
👍 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 { |
There was a problem hiding this comment.
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.
Signed-off-by: Carlos Martín <[email protected]>
Signed-off-by: Carlos Martín <[email protected]>
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
.