Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ic-asset-certification): include range header in streaming request certification #417

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/ic-asset-certification/src/asset_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,10 @@ impl<'content> AssetRouter<'content> {
http::header::CONTENT_RANGE.to_string(),
format!("bytes {range_begin}-{range_end}/{total_length}"),
));
request_headers.push(http::header::RANGE.to_string());
request_headers.push((
http::header::RANGE.to_string(),
format!("bytes={range_begin}-"),
nathanosdev marked this conversation as resolved.
Show resolved Hide resolved
));
};

Self::prepare_response_and_certification(
Expand All @@ -925,7 +928,7 @@ impl<'content> AssetRouter<'content> {
status_code: StatusCode,
body: Cow<'content, [u8]>,
additional_response_headers: Vec<(String, String)>,
certified_request_headers: Vec<String>,
certified_request_headers: Vec<(String, String)>,
nathanosdev marked this conversation as resolved.
Show resolved Hide resolved
) -> AssetCertificationResult<(HttpResponse<'content>, HttpCertification)> {
let mut headers = vec![("content-length".to_string(), body.len().to_string())];

Expand All @@ -934,7 +937,7 @@ impl<'content> AssetRouter<'content> {
.with_request_headers(
certified_request_headers
.iter()
.map(|s| s.as_str())
.map(|(s, _)| s.as_str())
nathanosdev marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<&str>>(),
)
.with_response_certification(DefaultResponseCertification::response_header_exclusions(
Expand All @@ -944,7 +947,9 @@ impl<'content> AssetRouter<'content> {
let cel_expr_str = cel_expr.to_string();
headers.push((CERTIFICATE_EXPRESSION_HEADER_NAME.to_string(), cel_expr_str));

let request = HttpRequest::get(url).build();
let request = HttpRequest::get(url)
.with_headers(certified_request_headers.clone())
nathanosdev marked this conversation as resolved.
Show resolved Hide resolved
.build();

let response = HttpResponse::builder()
.with_status_code(status_code)
Expand Down
Loading