From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 028051FF173
	for <inbox@lore.proxmox.com>; Mon,  9 Dec 2024 10:57:36 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 783062E245;
	Mon,  9 Dec 2024 10:57:38 +0100 (CET)
Date: Mon, 9 Dec 2024 10:57:34 +0100
From: Christoph Heiss <c.heiss@proxmox.com>
To: Daniel Kral <d.kral@proxmox.com>
Message-ID: <u4j5k42lx4dmxqt6ilmvgwlhc6yvcnkbvhjy4mrdpcurvqfptl@6crh726nemwl>
References: <20241206132455.145355-1-d.kral@proxmox.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <20241206132455.145355-1-d.kral@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.028 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [RFC PATCH installer] auto: allow a binary
 executable as the first boot executable
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Apart from one note inline, LGTM overall.

On Fri, Dec 06, 2024 at 02:24:55PM +0100, Daniel Kral wrote:
> [..]
> When the HTTP response is missing the "Content-Length" header, it will
> be explicitly stated in the error message.

Why mandate the `Content-Length` header tho? For HTTP/1.1, it is only
marked SHOULD [0] and for HTTP2, it is actually completely optional [1].

I've just tested it w/ and w/o the patch, both work just fine if no
`Content-Length` header is sent back.

(Admittedly, only with a plain-text script - but that is the more likely
usage anyway.)

[0] https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
[1] https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.6

> [..]
> diff --git a/proxmox-installer-common/src/http.rs b/proxmox-installer-common/src/http.rs
> index f4afe14..a748266 100644
> --- a/proxmox-installer-common/src/http.rs
> +++ b/proxmox-installer-common/src/http.rs
> [..]
> +pub fn get_as_bytes(url: &str, fingerprint: Option<&str>, max_size: usize) -> Result<Vec<u8>> {
> +    let mut result: Vec<u8> = Vec::new();
> +
> +    let response = build_agent(fingerprint)?
>          .get(url)
>          .timeout(std::time::Duration::from_secs(60))
> -        .call()?
> -        .into_string()?)
> +        .call()?;
> +
> +    match response
> +        .into_reader()
> +        .take(max_size as u64)
> +        .read_to_end(&mut result)
> +    {
> +        Err(ref err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {
> +            bail!("Unexpected end of line. Does the HTTP server provide a Content-Length header?")
> +        }

Since the `Content-Length` header isn't actually required, the message
is misleading.

I wouldn't handle `UnexpectedEof` special here, instead just like any
other error - since it does not really indicate anything specific.

> +        Err(err) => bail!("Error while reading GET request: {err}"),
> +        Ok(_) => Ok(result),
> +    }
>  }
>


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel