Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Set correct content type to HTTP responses #89

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ anyhow = "1.0"
flate2 = "1.0"
futures = "0.3"
http = "0.2"
integration-test-commons = { git = "https://github.com/stackabletech/integration-test-commons.git", tag = "0.5.0" }
integration-test-commons = { git = "https://github.com/stackabletech/integration-test-commons.git", tag = "0.6.0" }
k8s-openapi = { version = "0.13", default-features = false, features = ["v1_22"] }
kube = { version = "0.60", features = ["derive"] }
nix = "0.23"
Expand Down
11 changes: 9 additions & 2 deletions tests/util/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::{collections::HashMap, net::SocketAddr};

use anyhow::anyhow;
use anyhow::Result;
use http::Uri;
use http::header::CONTENT_TYPE;
use http::{HeaderValue, Response, Uri};
use integration_test_commons::test::kube::KubeClient;
use kube::CustomResource;
use nix::ifaddrs;
Expand All @@ -13,6 +14,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha512};
use tokio::sync::oneshot::{self, Sender};
use warp::hyper::Body;
use warp::{path::FullPath, Filter};

use super::test_package::TestPackage;
Expand Down Expand Up @@ -222,7 +224,12 @@ fn serve(packages: &[TestPackage]) -> Result<(SocketAddr, Sender<()>)> {
packages
.iter()
.find(|package| format!("/{}", package.repository_path()) == path.as_str())
.map(|package| package.binary())
.map(|package| {
Response::builder()
.header(CONTENT_TYPE, HeaderValue::from_static("application/gzip"))
.body(Body::from(package.binary()))
.unwrap()
})
.ok_or_else(warp::reject::not_found)
}
});
Expand Down