-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add support for user:pass in URLs #614
Conversation
buf = append(buf, uri.password...) | ||
buf = buf[:tl] | ||
base64.StdEncoding.Encode(buf[nl:], buf[:nl]) | ||
req.Header.SetBytesKV(strAuthorization, buf[nl:]) |
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 agree this is all a bit dirty to use the scratch buffer of the req.Header
. But the alternative would be to have another sync.Pool
for []byte
just for this.
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.
Maybe this would help https://go-review.googlesource.com/c/go/+/37639/1/src/encoding/base64/base64.go
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.
That would change these lines:
buf = buf[:tl]
base64.StdEncoding.Encode(buf[nl:], buf[:nl])
into:
buf = base64.StdEncoding.AppendEncode(buf, buf[:nl])
but it wouldn't help avoiding with the allocation.
It's not work. My test URL is https://user1:pass1@sub.domain.com. |
@paween1980 maybe it's what you pointed out here? |
@paween1980 what doesn't work? Please share your code. It seems to work fine here: https://play.golang.org/p/M-I-i8VC1Kd |
@paween1980 I see now, thanks for telling us! It should be fixed in 1d6a7e0 |
Fixes #609