From 33f685f8958876461bdb31f56e39e63142ec7bf6 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 27 Feb 2026 11:56:11 +0300 Subject: [PATCH] Take Content-Length is no -size is specified --- cmd/dl.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 { -- 2.52.0