Skip to content

Commit

Permalink
remove cost
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Nov 23, 2017
1 parent 2b1eb5e commit ae4c839
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 21 deletions.
7 changes: 0 additions & 7 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,5 @@ func (r *Resp) Dump() string {

r.dumpResponse(dump)

cost := r.r.flag&Lcost != 0
if cost {
if dump.Len() > l {
dump.WriteString("=================================")
}
dump.WriteString("cost: " + r.cost.String())
}
return dump.String()
}
2 changes: 0 additions & 2 deletions req.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
resp.client = r.Client()
}

now := time.Now()
response, err := resp.client.Do(req)
resp.cost = time.Since(now)
if err != nil {
return nil, err
}
Expand Down
12 changes: 0 additions & 12 deletions resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ type Resp struct {
reqBody []byte
respBody []byte
downloadProgress DownloadProgress
cost time.Duration
err error // delayed error
}

// Cost returns time spent by the request
func (r *Resp) Cost() time.Duration {
return r.cost
}

// Request returns *http.Request
func (r *Resp) Request() *http.Request {
return r.req
Expand Down Expand Up @@ -153,9 +147,6 @@ var regNewline = regexp.MustCompile(`\n|\r`)
func (r *Resp) autoFormat(s fmt.State) {
req := r.req
fmt.Fprint(s, req.Method, " ", req.URL.String())
if r.r.flag&Lcost != 0 {
fmt.Fprint(s, " ", r.cost.String())
}

// test if it is should be outputed pretty
var pretty bool
Expand Down Expand Up @@ -187,9 +178,6 @@ func (r *Resp) autoFormat(s fmt.State) {
func (r *Resp) miniFormat(s fmt.State) {
req := r.req
fmt.Fprint(s, req.Method, " ", req.URL.String())
if r.r.flag&Lcost != 0 {
fmt.Fprint(s, " ", r.cost.String())
}
if r.r.flag&LreqBody != 0 && len(r.reqBody) > 0 { // request body
str := regNewline.ReplaceAllString(string(r.reqBody), " ")
fmt.Fprint(s, " ", str)
Expand Down

0 comments on commit ae4c839

Please sign in to comment.