)
func BasicAuth(r *http.Request) (username, password string, ok bool) {
- toks := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
- if len(toks) != 2 || toks[0] != "Basic" {
+ tokens := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
+ if len(tokens) != 2 || tokens[0] != "Basic" {
return "", "", false
}
- decoded, err := base64.StdEncoding.DecodeString(toks[1])
+ decoded, err := base64.StdEncoding.DecodeString(tokens[1])
if err != nil {
return "", "", false
}
go w.Close()
output, err := cmd.CombinedOutput()
c.Log("git ", gitargs, " => ", err)
- if err != nil {
- // Easier to match error strings without newlines.
+ if err != nil && len(output) > 0 {
+ // If messages appeared on stderr, they are more
+ // helpful than the err returned by CombinedOutput().
+ //
+ // Easier to match error strings without newlines:
err = errors.New(strings.Replace(string(output), "\n", " // ", -1))
}
return err