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

proposal: net/http: Export parseBasicAuth #22332

mlowicki opened this issue Oct 18, 2017 · 2 comments


None yet
4 participants
Copy link

commented Oct 18, 2017

Currently parseBasicAuth is not exported and used only by BasicAuth function which always uses "Authorization" header. Proxy server can use something like "Proxy-Authorization" or "XXX-Proxy-Authorization" headers and currently it's not possible to reuse parseBasicAuth to parse basic auth payload there. My proposal would be to simply export this function so proxy servers could apply it like:

    auth := r.Header.Get("XXX-Proxy-Authorization")
    if auth == "" {
        http.Error(w, "", http.StatusProxyAuthRequired)
    username, password, ok := http.ParseBasicAuth(auth)

@odeke-em odeke-em changed the title Export `parseBasicAuth` from `http` package proposal: net/http: Export parseBasicAuth Oct 18, 2017

@gopherbot gopherbot added this to the Proposal milestone Oct 18, 2017

@gopherbot gopherbot added the Proposal label Oct 18, 2017


This comment has been minimized.

Copy link

commented Oct 18, 2017


This comment has been minimized.

Copy link

commented Oct 18, 2017

parseBasicAuth is trivial: trim "Basic ", decode base64, split on ":". I do not think it's worth expanding the API just so that custom headers can reuse those same 14 lines of code.

@tombergan tombergan closed this Oct 18, 2017

@golang golang locked and limited conversation to collaborators Oct 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.