Skip to content

Commit

Permalink
Merge pull request #4334 from wasmerio/download-package-content-type
Browse files Browse the repository at this point in the history
Add `application/wasm` to list of accepted content-types for webcs
  • Loading branch information
Michael Bryan authored Nov 30, 2023
2 parents e643873 + 49cd7d2 commit b38aa5c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/cli/src/commands/package/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,21 @@ impl PackageDownload {
pb.set_length(webc_total_size);

let mut tmpfile = NamedTempFile::new_in(self.out_path.parent().unwrap())?;

let accepted_contenttypes = vec![
"application/webc",
"application/octet-stream",
"application/wasm",
];
let ty = res
.headers()
.get(http::header::CONTENT_TYPE)
.and_then(|t| t.to_str().ok())
.unwrap_or_default();
if !(ty == "application/webc" || ty == "application/octet-stream") {
if !(accepted_contenttypes.contains(&ty)) {
eprintln!(
"Warning: response has invalid content type - expected \
'application/webc' or 'application/octet-stream', got {ty}"
one of {:?}, got {ty}",
accepted_contenttypes
);
}

Expand Down

0 comments on commit b38aa5c

Please sign in to comment.