Refactored out usage of strconv.Quote()

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
pull/4/head
Josh Hawn 2014-12-17 16:16:02 -08:00
parent 2e3af8efcf
commit 4c42477abf
1 changed files with 4 additions and 5 deletions

View File

@ -9,7 +9,6 @@ import (
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"github.com/docker/libtrust"
@ -97,16 +96,16 @@ func (ac *authChallenge) Status() int {
// the WWW-Authenticate response challenge header.
// See https://tools.ietf.org/html/rfc6750#section-3
func (ac *authChallenge) challengeParams() string {
str := fmt.Sprintf("Bearer realm=%s,service=%s", strconv.Quote(ac.realm), strconv.Quote(ac.service))
str := fmt.Sprintf("Bearer realm=%q,service=%q", ac.realm, ac.service)
if scope := ac.accessSet.scopeParam(); scope != "" {
str = fmt.Sprintf("%s,scope=%s", str, strconv.Quote(scope))
str = fmt.Sprintf("%s,scope=%q", str, scope)
}
if ac.err == ErrInvalidToken || ac.err == ErrMalformedToken {
str = fmt.Sprintf("%s,error=%s", str, strconv.Quote("invalid_token"))
str = fmt.Sprintf("%s,error=%q", str, "invalid_token")
} else if ac.err == ErrInsufficientScope {
str = fmt.Sprintf("%s,error=%s", str, strconv.Quote("insufficient_scope"))
str = fmt.Sprintf("%s,error=%q", str, "insufficient_scope")
}
return str