Skip to content

Commit

Permalink
chore: use httpdate to format expires
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Aug 27, 2024
1 parent b22e843 commit 0d1831b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions crates/volta-core/src/tool/node/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use attohttpc::header::HeaderMap;
use attohttpc::Response;
use cfg_if::cfg_if;
use fs_utils::ensure_containing_dir_exists;
use headers::{CacheControl, Expires, Header, HeaderMapExt};
use headers::{CacheControl, Expires, HeaderMapExt};
use log::debug;
use node_semver::{Range, Version};

Expand Down Expand Up @@ -245,12 +245,9 @@ fn resolve_node_versions(url: &str) -> Fallible<RawNodeIndex> {
let expiry = create_staging_file()?;
let mut expiry_file: &File = expiry.as_file();

let mut header_values = Vec::with_capacity(1);
expires.encode(&mut header_values);
// Since we just `.encode()`d into `header_values
let encoded_expires = header_values.first().unwrap().to_str().unwrap();
let formatted_expires = httpdate::fmt_http_date(SystemTime::from(expires));

write!(expiry_file, "{}", encoded_expires).with_context(|| {
write!(expiry_file, "{}", formatted_expires).with_context(|| {
ErrorKind::WriteNodeIndexExpiryError {
file: expiry.path().to_path_buf(),
}
Expand Down

0 comments on commit 0d1831b

Please sign in to comment.