Skip to content

Commit a5fdbd1

Browse files
committed
improve
1 parent 7be7cc9 commit a5fdbd1

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

objectstore-server/src/endpoints/objects.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,11 @@ async fn object_get(
110110
let mut response = (status, metadata_headers, Body::from_stream(stream)).into_response();
111111
let resp_headers = response.headers_mut();
112112
resp_headers.insert(http::header::ACCEPT_RANGES, "bytes".parse().unwrap());
113-
if content_range.total > 0 {
113+
if !content_range.is_full() {
114114
resp_headers.insert(
115115
http::header::CONTENT_LENGTH,
116116
content_range.len().to_string().parse().unwrap(),
117117
);
118-
}
119-
if !content_range.is_full() {
120118
resp_headers.insert(
121119
http::header::CONTENT_RANGE,
122120
content_range.to_header_value().parse().unwrap(),

objectstore-service/src/backend/gcs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,10 @@ impl Backend for GcsBackend {
700700
.get(header::CONTENT_RANGE)
701701
.and_then(|v| v.to_str().ok())
702702
.and_then(ContentRange::parse)
703-
.unwrap_or_else(|| {
704-
ContentRange::full(payload_response.content_length().unwrap_or(0))
705-
})
703+
.ok_or_else(|| Error::Generic {
704+
context: "GCS: 206 response missing valid Content-Range header".to_owned(),
705+
cause: None,
706+
})?
706707
} else {
707708
ContentRange::full(metadata.size.unwrap_or(0) as u64)
708709
};

objectstore-service/src/backend/s3_compatible.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ impl<T: TokenProvider> Backend for S3CompatibleBackend<T> {
326326
.get(reqwest::header::CONTENT_RANGE)
327327
.and_then(|v| v.to_str().ok())
328328
.and_then(ContentRange::parse)
329-
.unwrap_or_else(|| ContentRange::full(response.content_length().unwrap_or(0)))
329+
.ok_or_else(|| Error::Generic {
330+
context: "S3: 206 response missing valid Content-Range header".to_owned(),
331+
cause: None,
332+
})?
330333
} else {
331334
ContentRange::full(metadata.size.unwrap_or(0) as u64)
332335
};

0 commit comments

Comments
 (0)