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)
if c.IsLogging {
c.StartResponseStats(res, start)
}
c.startResponseStats(res, start)
if res.StatusCode != 307 {
return res, err

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

@ -19,6 +19,10 @@ type httpTransfer struct {
}
func (c *Client) LogResponse(key string, res *http.Response) {
if !c.LoggingStats {
return
}
c.transferBucketMu.Lock()
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)
}
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
resHeaderSize := 0
@ -56,7 +64,11 @@ func (c *Client) StartResponseStats(res *http.Response, start time.Time) {
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()
defer c.transferMu.Unlock()

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