Skip to content

Commit

Permalink
refactor: rename header functions
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Nov 9, 2023
1 parent 69de093 commit 896cb6c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/satellite/src/storage/certification/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::storage::constants::{
ENCODING_CERTIFICATION_ORDER, RESPONSE_STATUS_CODE_200, RESPONSE_STATUS_CODE_404,
ROOT_404_HTML, ROOT_INDEX_HTML, ROOT_PATH,
};
use crate::storage::http::headers::{build_asset_headers, build_redirect_headers};
use crate::storage::http::headers::{build_headers, build_redirect_headers};
use crate::storage::http::types::{HeaderField, StatusCode};
use crate::storage::types::state::FullPath;
use crate::storage::types::store::Asset;
Expand Down Expand Up @@ -93,7 +93,7 @@ impl CertifiedAssetHashes {
self.insert_v1(&full_path, encoding.sha256);
self.insert_v2(
&full_path,
&build_asset_headers(asset, encoding, &encoding_type.to_string()),
&build_headers(asset, encoding, &encoding_type.to_string()),
RESPONSE_STATUS_CODE_200,
encoding.sha256,
);
Expand Down Expand Up @@ -211,7 +211,7 @@ impl CertifiedAssetHashes {
if let Some(encoding) = asset.encodings.get(*encoding_type) {
self.insert_rewrite_into_tree_v2(
full_path,
&build_asset_headers(asset, encoding, &encoding_type.to_string()),
&build_headers(asset, encoding, &encoding_type.to_string()),
encoding.sha256,
RESPONSE_STATUS_CODE_200,
);
Expand Down
5 changes: 3 additions & 2 deletions src/satellite/src/storage/http/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::storage::types::store::{Asset, AssetEncoding, EncodingType};
use crate::storage::url::matching_urls;
use hex::encode;

pub fn build_asset_headers(
pub fn build_headers(
asset: &Asset,
encoding: &AssetEncoding,
encoding_type: &EncodingType,
Expand Down Expand Up @@ -72,7 +72,8 @@ pub fn build_config_headers(
..
}: &StorageConfig,
) -> Vec<HeaderField> {
matching_urls(requested_path, config_headers).iter()
matching_urls(requested_path, config_headers)
.iter()
.flat_map(|(_, headers)| headers.clone())
.collect()
}
6 changes: 3 additions & 3 deletions src/satellite/src/storage/http/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::storage::constants::{
};
use crate::storage::http::types::{HeaderField, HttpResponse, StatusCode};
use crate::storage::http::utils::{
build_encodings, build_headers, build_redirect_headers_response, streaming_strategy,
build_encodings, build_response_headers, build_response_redirect_headers, streaming_strategy,
};
use crate::storage::types::store::Asset;

Expand All @@ -25,7 +25,7 @@ pub fn build_asset_response(

for encoding_type in encodings.iter() {
if let Some(encoding) = asset.encodings.get(encoding_type) {
let headers = build_headers(
let headers = build_response_headers(
&requested_url,
&asset,
encoding,
Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn build_redirect_response(
redirect: &StorageConfigRedirect,
) -> HttpResponse {
let headers =
build_redirect_headers_response(&requested_url, &redirect.location, &certificate_version)
build_response_redirect_headers(&requested_url, &redirect.location, &certificate_version)
.unwrap();

HttpResponse {
Expand Down
8 changes: 4 additions & 4 deletions src/satellite/src/storage/http/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::storage::certification::cert::{
build_asset_certificate_header, build_certified_expression,
};
use crate::storage::constants::ASSET_ENCODING_NO_COMPRESSION;
use crate::storage::http::headers::{build_asset_headers, build_redirect_headers};
use crate::storage::http::headers::{build_headers, build_redirect_headers};
use crate::storage::http::types::{
CallbackFunc, HeaderField, StreamingCallbackToken, StreamingStrategy,
};
Expand Down Expand Up @@ -52,20 +52,20 @@ pub fn create_token(
})
}

pub fn build_headers(
pub fn build_response_headers(
url: &str,
asset: &Asset,
encoding: &AssetEncoding,
encoding_type: &EncodingType,
certificate_version: &Option<u16>,
rewrite_source: &Option<String>,
) -> Result<Vec<HeaderField>, &'static str> {
let asset_headers = build_asset_headers(asset, encoding, encoding_type);
let asset_headers = build_headers(asset, encoding, encoding_type);

extend_headers_with_certification(asset_headers, url, certificate_version, rewrite_source)
}

pub fn build_redirect_headers_response(
pub fn build_response_redirect_headers(
url: &str,
location: &str,
certificate_version: &Option<u16>,
Expand Down

0 comments on commit 896cb6c

Please sign in to comment.