Skip to content

Commit 5817cef

Browse files
authored
fix(ic-asset-certification): include range header in streaming request certification (#417)
1 parent 2e6418b commit 5817cef

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/ic-asset-certification/src/asset_router.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,10 @@ impl<'content> AssetRouter<'content> {
908908
http::header::CONTENT_RANGE.to_string(),
909909
format!("bytes {range_begin}-{range_end}/{total_length}"),
910910
));
911-
request_headers.push(http::header::RANGE.to_string());
911+
request_headers.push((
912+
http::header::RANGE.to_string(),
913+
format!("bytes={range_begin}-"),
914+
));
912915
};
913916

914917
Self::prepare_response_and_certification(
@@ -925,7 +928,7 @@ impl<'content> AssetRouter<'content> {
925928
status_code: StatusCode,
926929
body: Cow<'content, [u8]>,
927930
additional_response_headers: Vec<(String, String)>,
928-
certified_request_headers: Vec<String>,
931+
certified_request_headers: Vec<(String, String)>,
929932
) -> AssetCertificationResult<(HttpResponse<'content>, HttpCertification)> {
930933
let mut headers = vec![("content-length".to_string(), body.len().to_string())];
931934

@@ -934,7 +937,7 @@ impl<'content> AssetRouter<'content> {
934937
.with_request_headers(
935938
certified_request_headers
936939
.iter()
937-
.map(|s| s.as_str())
940+
.map(|(s, _)| s.as_str())
938941
.collect::<Vec<&str>>(),
939942
)
940943
.with_response_certification(DefaultResponseCertification::response_header_exclusions(
@@ -944,7 +947,9 @@ impl<'content> AssetRouter<'content> {
944947
let cel_expr_str = cel_expr.to_string();
945948
headers.push((CERTIFICATE_EXPRESSION_HEADER_NAME.to_string(), cel_expr_str));
946949

947-
let request = HttpRequest::get(url).build();
950+
let request = HttpRequest::get(url)
951+
.with_headers(certified_request_headers.clone())
952+
.build();
948953

949954
let response = HttpResponse::builder()
950955
.with_status_code(status_code)

0 commit comments

Comments
 (0)