From b9bfcb50a3d5df4c5d67427e393aa09e86bc2840 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Thu, 21 Oct 2021 09:45:00 +0530 Subject: [PATCH] Fix subnet login during registration not working (#3841) Subnet doesn't return `ContentLength` in it's api response, and hence using it as the limit with `LimitReader` doesn't work. Fixed by using a sufficiently large (1 MiB) limit. --- cmd/subnet-utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/subnet-utils.go b/cmd/subnet-utils.go index ca52094e..bdd01d40 100644 --- a/cmd/subnet-utils.go +++ b/cmd/subnet-utils.go @@ -41,7 +41,10 @@ import ( "golang.org/x/crypto/ssh/terminal" ) -const minioSubscriptionURL = "https://min.io/subscription" +const ( + subnetRespBodyLimit = 1 << 20 // 1 MiB + minioSubscriptionURL = "https://min.io/subscription" +) var subnetCommonFlags = []cli.Flag{ cli.StringFlag{ @@ -158,7 +161,7 @@ func subnetExecReq(r *http.Request, headers map[string]string) (string, error) { } defer resp.Body.Close() - respBytes, e := ioutil.ReadAll(io.LimitReader(resp.Body, resp.ContentLength)) + respBytes, e := ioutil.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit)) if e != nil { return "", e }