Skip to content

Commit

Permalink
refactor: simplify writerWrapper.enoughContentLength()
Browse files Browse the repository at this point in the history
  • Loading branch information
nanmu42 committed Nov 29, 2020
1 parent b0483ce commit 96ed5c7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions writerwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,10 @@ func (w *writerWrapper) writeBuffer(data []byte) (fit bool) {
}

func (w *writerWrapper) enoughContentLength() bool {
var (
header = w.Header()
_, haveCl = header["Content-Length"]
contentLength int64
)
if haveCl {
contentLength, _ = strconv.ParseInt(header.Get("Content-Length"), 10, 64)
contentLength, err := strconv.ParseInt(w.Header().Get("Content-Length"), 10, 64)
if err != nil {
return false
}

if contentLength != 0 && contentLength >= w.MinContentLength {
return true
}
Expand Down

0 comments on commit 96ed5c7

Please sign in to comment.