Skip to content

Commit 5bf58f0

Browse files
authored
Merge pull request #2862 from arik-so/arik/2024/01/http-error-message-fix
Improve error message for invalid response lengths
2 parents a634fd1 + bb9b389 commit 5bf58f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning-block-sync/src/http.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl HttpClient {
288288
HttpMessageLength::Empty => { Vec::new() },
289289
HttpMessageLength::ContentLength(length) => {
290290
if length == 0 || length > MAX_HTTP_MESSAGE_BODY_SIZE {
291-
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "out of range"))
291+
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, format!("invalid response length: {} bytes", length)));
292292
} else {
293293
let mut content = vec![0; length];
294294
#[cfg(feature = "tokio")]
@@ -727,7 +727,7 @@ pub(crate) mod client_tests {
727727
match client.get::<BinaryResponse>("/foo", "foo.com").await {
728728
Err(e) => {
729729
assert_eq!(e.kind(), std::io::ErrorKind::InvalidData);
730-
assert_eq!(e.get_ref().unwrap().to_string(), "out of range");
730+
assert_eq!(e.get_ref().unwrap().to_string(), "invalid response length: 8032001 bytes");
731731
},
732732
Ok(_) => panic!("Expected error"),
733733
}

0 commit comments

Comments
 (0)