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