lfsapi: rename bools to closer match their env variants

This commit is contained in:
risk danger olson 2016-12-21 11:49:40 -07:00
parent 49b62826aa
commit f3bbe7bd90
4 changed files with 28 additions and 20 deletions

@ -42,9 +42,7 @@ func (c *Client) doWithRedirects(cli *http.Client, req *http.Request, via []*htt
} }
c.traceResponse(res) c.traceResponse(res)
if c.IsLogging { c.startResponseStats(res, start)
c.StartResponseStats(res, start)
}
if res.StatusCode != 307 { if res.StatusCode != 307 {
return res, err return res, err

@ -30,9 +30,9 @@ type Client struct {
NoProxy string NoProxy string
SkipSSLVerify bool SkipSSLVerify bool
IsTracing bool Verbose bool
IsDebugging bool DebuggingVerbose bool
IsLogging bool LoggingStats bool
hostClients map[string]*http.Client hostClients map[string]*http.Client
clientMu sync.Mutex clientMu sync.Mutex
@ -74,9 +74,9 @@ func NewClient(osEnv env, gitEnv env) (*Client, error) {
TLSTimeout: gitEnv.Int("lfs.tlstimeout", 0), TLSTimeout: gitEnv.Int("lfs.tlstimeout", 0),
ConcurrentTransfers: gitEnv.Int("lfs.concurrenttransfers", 0), ConcurrentTransfers: gitEnv.Int("lfs.concurrenttransfers", 0),
SkipSSLVerify: !gitEnv.Bool("http.sslverify", true) || osEnv.Bool("GIT_SSL_NO_VERIFY", false), SkipSSLVerify: !gitEnv.Bool("http.sslverify", true) || osEnv.Bool("GIT_SSL_NO_VERIFY", false),
IsTracing: osEnv.Bool("GIT_CURL_VERBOSE", false), Verbose: osEnv.Bool("GIT_CURL_VERBOSE", false),
IsDebugging: osEnv.Bool("LFS_DEBUG_HTTP", false), DebuggingVerbose: osEnv.Bool("LFS_DEBUG_HTTP", false),
IsLogging: osEnv.Bool("GIT_LOG_STATS", false), LoggingStats: osEnv.Bool("GIT_LOG_STATS", false),
HTTPSProxy: httpsProxy, HTTPSProxy: httpsProxy,
HTTPProxy: httpProxy, HTTPProxy: httpProxy,
NoProxy: noProxy, NoProxy: noProxy,

@ -19,6 +19,10 @@ type httpTransfer struct {
} }
func (c *Client) LogResponse(key string, res *http.Response) { func (c *Client) LogResponse(key string, res *http.Response) {
if !c.LoggingStats {
return
}
c.transferBucketMu.Lock() c.transferBucketMu.Lock()
defer c.transferBucketMu.Unlock() defer c.transferBucketMu.Unlock()
@ -29,7 +33,11 @@ func (c *Client) LogResponse(key string, res *http.Response) {
c.transferBuckets[key] = append(c.transferBuckets[key], res) c.transferBuckets[key] = append(c.transferBuckets[key], res)
} }
func (c *Client) StartResponseStats(res *http.Response, start time.Time) { func (c *Client) startResponseStats(res *http.Response, start time.Time) {
if !c.LoggingStats {
return
}
reqHeaderSize := 0 reqHeaderSize := 0
resHeaderSize := 0 resHeaderSize := 0
@ -56,7 +64,11 @@ func (c *Client) StartResponseStats(res *http.Response, start time.Time) {
c.transferMu.Unlock() c.transferMu.Unlock()
} }
func (c *Client) FinishResponseStats(res *http.Response, bodySize int64) { func (c *Client) finishResponseStats(res *http.Response, bodySize int64) {
if !c.LoggingStats || res == nil {
return
}
c.transferMu.Lock() c.transferMu.Lock()
defer c.transferMu.Unlock() defer c.transferMu.Unlock()

@ -17,7 +17,7 @@ func (c *Client) traceRequest(req *http.Request) error {
tracerx.Printf("HTTP: %s", traceReq(req)) tracerx.Printf("HTTP: %s", traceReq(req))
traced := &tracedRequest{ traced := &tracedRequest{
isTraceableType: c.IsTracing && isTraceableContent(req.Header), isTraceableType: c.Verbose && isTraceableContent(req.Header),
} }
body, ok := req.Body.(ReadSeekCloser) body, ok := req.Body.(ReadSeekCloser)
@ -29,7 +29,7 @@ func (c *Client) traceRequest(req *http.Request) error {
traced.ReadSeekCloser = body traced.ReadSeekCloser = body
} }
if !c.IsTracing { if !c.Verbose {
return nil return nil
} }
@ -60,9 +60,8 @@ func (c *Client) traceResponse(res *http.Response) *tracedResponse {
traced := &tracedResponse{ traced := &tracedResponse{
client: c, client: c,
response: res, response: res,
isLogging: c.IsLogging,
isTraceableType: isTraceable, isTraceableType: isTraceable,
useStderrTrace: c.IsTracing, useStderrTrace: c.Verbose,
} }
if res == nil { if res == nil {
@ -72,7 +71,7 @@ func (c *Client) traceResponse(res *http.Response) *tracedResponse {
traced.ReadCloser = res.Body traced.ReadCloser = res.Body
tracerx.Printf("HTTP: %d", res.StatusCode) tracerx.Printf("HTTP: %d", res.StatusCode)
if c.IsTracing == false { if c.Verbose == false {
return traced return traced
} }
@ -95,7 +94,6 @@ type tracedResponse struct {
Count int Count int
client *Client client *Client
response *http.Response response *http.Response
isLogging bool
isTraceableType bool isTraceableType bool
useStderrTrace bool useStderrTrace bool
io.ReadCloser io.ReadCloser
@ -105,8 +103,8 @@ func (r *tracedResponse) Read(b []byte) (int, error) {
n, err := tracedRead(r.ReadCloser, b, r.isTraceableType, true, r.useStderrTrace) n, err := tracedRead(r.ReadCloser, b, r.isTraceableType, true, r.useStderrTrace)
r.Count += n r.Count += n
if err == io.EOF && r.isLogging && r.response != nil { if err == io.EOF {
r.client.FinishResponseStats(r.response, int64(r.Count)) r.client.finishResponseStats(r.response, int64(r.Count))
} }
return n, err return n, err
} }
@ -134,7 +132,7 @@ func (c *Client) traceHTTPDump(direction string, dump []byte) {
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if !c.IsDebugging && strings.HasPrefix(strings.ToLower(line), "authorization: basic") { if !c.DebuggingVerbose && strings.HasPrefix(strings.ToLower(line), "authorization: basic") {
fmt.Fprintf(os.Stderr, "%s Authorization: Basic * * * * *\n", direction) fmt.Fprintf(os.Stderr, "%s Authorization: Basic * * * * *\n", direction)
} else { } else {
fmt.Fprintf(os.Stderr, "%s %s\n", direction, line) fmt.Fprintf(os.Stderr, "%s %s\n", direction, line)