From: Sergey Matveev Date: Fri, 27 Feb 2026 08:56:11 +0000 (+0300) Subject: Take Content-Length is no -size is specified X-Git-Tag: v1.5.0~2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=33f685f8958876461bdb31f56e39e63142ec7bf6;p=meta4ra.git Take Content-Length is no -size is specified --- diff --git a/cmd/dl.go b/cmd/dl.go index 3f41275..4097690 100644 --- a/cmd/dl.go +++ b/cmd/dl.go @@ -64,9 +64,17 @@ func runDl() { if resp.StatusCode != http.StatusOK { log.Fatalln("status code:", resp.Status) } + var sizeExpected uint64 + if *size == 0 { + if resp.ContentLength > 0 { + sizeExpected = uint64(resp.ContentLength) + } + } else { + sizeExpected = uint64(*size) + } var w io.Writer if *progress { - bar := Progress{w: os.Stdout, now: time.Now(), total: uint64(*size)} + bar := Progress{w: os.Stdout, now: time.Now(), total: sizeExpected} bar.next = bar.now.Add(ProgressPeriod) w = &bar } else {