From: Christoph Heiss <c.heiss@proxmox.com>
To: Daniel Kral <d.kral@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [RFC PATCH installer] auto: allow a binary executable as the first boot executable
Date: Mon, 9 Dec 2024 10:57:34 +0100 [thread overview]
Message-ID: <u4j5k42lx4dmxqt6ilmvgwlhc6yvcnkbvhjy4mrdpcurvqfptl@6crh726nemwl> (raw)
In-Reply-To: <20241206132455.145355-1-d.kral@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
next prev parent reply other threads:[~2024-12-09 9:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 13:24 Daniel Kral
2024-12-09 9:57 ` Christoph Heiss [this message]
2024-12-11 9:01 ` Daniel Kral
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u4j5k42lx4dmxqt6ilmvgwlhc6yvcnkbvhjy4mrdpcurvqfptl@6crh726nemwl \
--to=c.heiss@proxmox.com \
--cc=d.kral@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox