add full http debug mode

This commit is contained in:
risk danger olson 2015-11-18 09:41:29 -07:00
parent f5966257bd
commit adfea0da4e
2 changed files with 8 additions and 6 deletions

@ -49,6 +49,7 @@ type Configuration struct {
ntlmSession ntlm.ClientSession
envVars map[string]string
isTracingHttp bool
isDebuggingHttp bool
isLoggingStats bool
loading sync.Mutex // guards initialization of gitConfig and remotes
@ -67,6 +68,7 @@ func NewConfig() *Configuration {
envVars: make(map[string]string),
}
c.isTracingHttp = c.GetenvBool("GIT_CURL_VERBOSE", false)
c.isDebuggingHttp = c.GetenvBool("LFS_DEBUG_HTTP", false)
c.isLoggingStats = c.GetenvBool("GIT_LOG_STATS", false)
return c
}

@ -158,7 +158,7 @@ func traceHttpRequest(req *http.Request) {
return
}
traceHttpDump(dump)
traceHttpDump(">", dump)
}
func traceHttpResponse(res *http.Response) {
@ -183,18 +183,18 @@ func traceHttpResponse(res *http.Response) {
fmt.Fprintf(os.Stderr, "\n")
}
traceHttpDump(dump)
traceHttpDump("<", dump)
}
func traceHttpDump(dump []byte) {
func traceHttpDump(direction string, dump []byte) {
scanner := bufio.NewScanner(bytes.NewBuffer(dump))
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix("authorization: basic", strings.ToLower(line)) {
fmt.Fprintf(os.Stderr, "< Authorization: Basic * * * * *\n")
if !Config.isDebuggingHttp && strings.HasPrefix(strings.ToLower(line), "authorization: basic") {
fmt.Fprintf(os.Stderr, "%s Authorization: Basic * * * * *\n", direction)
} else {
fmt.Fprintf(os.Stderr, "< %s\n", line)
fmt.Fprintf(os.Stderr, "%s %s\n", direction, line)
}
}
}