Skip to content

Commit

Permalink
fix(rad): http-head response headers can contain 'accept-ranges'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Nov 14, 2023
1 parent cd4641c commit f1314a4
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions rad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,16 @@ async fn http_response(
let (parts, mut body) = response.into_parts();

let response: RadonTypes;
if parts.headers.contains_key("accept-ranges") {
if retrieve.kind != RADType::HttpHead && parts.headers.contains_key("accept-ranges") {
// http response is a binary stream
let mut response_bytes = Vec::<u8>::default();
match retrieve.kind {
RADType::HttpHead => {
return Err(RadError::BufferIsNotValue {
description: String::from("Unsupported binary streams from HTTP/HEAD sources")
});
}
_ => {
// todo: before reading the response buffer, an error should be thrown if it was too big
body.read_to_end(&mut response_bytes).await.map_err(|x| {
RadError::HttpOther {
message: x.to_string(),
}
})?;

// todo: before reading the response buffer, an error should be thrown if it was too big
body.read_to_end(&mut response_bytes).await.map_err(|x| {
RadError::HttpOther {
message: x.to_string(),
}
}
})?;
response = RadonTypes::from(RadonBytes::from(response_bytes));
} else {
// response is a string
Expand Down

0 comments on commit f1314a4

Please sign in to comment.