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

Add support for user:pass in URLs #614

Merged
merged 1 commit into from
Aug 18, 2019
Merged

Conversation

erikdubbelboer
Copy link
Collaborator

Fixes #609

buf = append(buf, uri.password...)
buf = buf[:tl]
base64.StdEncoding.Encode(buf[nl:], buf[:nl])
req.Header.SetBytesKV(strAuthorization, buf[nl:])
Copy link
Collaborator Author

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.

Copy link
Contributor

@dgrr dgrr Jul 20, 2019

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

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.

@erikdubbelboer erikdubbelboer merged commit 2edabf3 into master Aug 18, 2019
@erikdubbelboer erikdubbelboer deleted the username-password-in-url branch August 18, 2019 09:23
@paween1980
Copy link

It's not work. My test URL is https://user1:pass1@sub.domain.com.
It's not set authorize Header correctly.

@dgrr
Copy link
Contributor

dgrr commented Sep 27, 2019

@paween1980 maybe it's what you pointed out here?

@erikdubbelboer
Copy link
Collaborator Author

@paween1980 what doesn't work? Please share your code. It seems to work fine here: https://play.golang.org/p/M-I-i8VC1Kd

@erikdubbelboer
Copy link
Collaborator Author

@paween1980 I see now, thanks for telling us! It should be fixed in 1d6a7e0

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.

Can we support user:pass in RequestURIs?
3 participants