-
Notifications
You must be signed in to change notification settings - Fork 718
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
Allow the Request to override the Authorization header set by the Client #121
Conversation
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
==========================================
+ Coverage 96.32% 96.32% +<.01%
==========================================
Files 10 10
Lines 1033 1035 +2
==========================================
+ Hits 995 997 +2
Misses 21 21
Partials 17 17
Continue to review full report at Codecov.
|
@arun251 Thank you for the PR. I will verify this behaviour between v0.13 and latest. I good to ensure any other singleton header also is not affected. |
@arun251 If there is an issue with singleton headers, that needs to be fixed across not just Authorization. Thanks for your findings. I will analyze and get back to you. |
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.
@arun251 I have found the reason and fix for across headers. I have provided fix info via review comments. Can you please update your PR and submit it?
@@ -472,3 +472,20 @@ func TestSetLogPrefix(t *testing.T) { | |||
assertEqual(t, "CUSTOM ", c.logPrefix) | |||
assertEqual(t, "CUSTOM ", c.Log.Prefix()) | |||
} | |||
|
|||
func TestRequestOverridesClientAuthorizationHeader(t *testing.T) { |
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.
Please move this test case to request_test.go
file.
@@ -76,6 +76,11 @@ func parseRequestHeader(c *Client, r *Request) error { | |||
hdr[k] = append(hdr[k], r.Header[k]...) | |||
} | |||
|
|||
// Allow the Request to override the Authorization header set by the Client |
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 have analyzed the v0.13 and latest version. Fix for across headers.
Remove this if condition and update your PR as follows.
Update Line #75 to #77 to following-
for k := range r.Header {
// remove header from client level by key
// since overrides happens for that key in the request
hdr.Del(k)
hdr[k] = append(hdr[k], r.Header[k]...)
}
@arun251 Awaiting for your PR changes or let me know I will do it. |
Please go ahead with the changes. Thanks! |
@arun251 Thank you, I will take your test case and create new PR. |
We have code that sets the
Authorization
header on theClient
object and then overrides the header on theRequest
object. That previously worked with Resty v0.13 but no longer worked after upgrading to Resty v1.2. The root cause of this issue is inparseRequestHeader
where client and request headers are concatenated.This PR fixes the issue for
Authorization
, but I suspect there are other singleton headers that could be affected.