address build issues and also use builder class for Client (#17)

This commit is contained in:
Harshavardhana 2022-08-22 22:30:06 -07:00 committed by GitHub
parent 20c0150d3d
commit 1888666d4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 42 deletions

View File

@ -1,30 +0,0 @@
name: MinIO Rust Library
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Check style
run: |
cargo build --verbose
cargo fmt --all -- --check
- name: Run tests
run: |
./start-server.sh
export SERVER_ENDPOINT=https://localhost:9000/
export ACCESS_KEY=minioadmin
export SECRET_KEY=minioadmin
cargo test --verbose -- --nocapture

View File

@ -1,4 +1,4 @@
name: Rust
name: MinIO Rust Library
on:
push:
@ -16,7 +16,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Build and Check style
run: |
cargo build --verbose
cargo fmt --all -- --check
- name: Run tests
run: cargo test --verbose
run: |
./start-server.sh
export SERVER_ENDPOINT=localhost:9000
export ACCESS_KEY=minioadmin
export SECRET_KEY=minioadmin
cargo test --verbose -- --nocapture

View File

@ -202,11 +202,11 @@ fn parse_list_objects_common_prefixes(
pub struct Client<'a> {
base_url: BaseUrl,
provider: Option<&'a dyn Provider>,
ssl_cert_file: String,
ignore_cert_check: bool,
region_map: DashMap<String, String>,
user_agent: String,
debug: bool,
ignore_cert_check: bool,
ssl_cert_file: String,
region_map: DashMap<String, String>,
}
impl<'a> Client<'a> {
@ -214,11 +214,11 @@ impl<'a> Client<'a> {
Client {
base_url: base_url,
provider: provider,
user_agent: String::new(),
debug: false,
ssl_cert_file: String::new(), // TODO: use specified ssl_cert_file
ignore_cert_check: false,
ssl_cert_file: String::new(),
region_map: DashMap::new(),
user_agent: String::new(), // TODO: use specified user_agent
debug: false,
}
}
@ -456,7 +456,18 @@ impl<'a> Client<'a> {
.build_url(&method, region, query_params, bucket_name, object_name)?;
self.build_headers(headers, query_params, region, &url, &method, body);
let client = reqwest::Client::new();
let client;
if object_name.unwrap_or_default().to_string().is_empty() && method == Method::GET {
client = reqwest::Client::builder()
.no_gzip() // needed to ensure no automatic decompression on GetObject
.danger_accept_invalid_certs(self.ignore_cert_check)
.build()?;
} else {
client = reqwest::Client::builder()
.danger_accept_invalid_certs(self.ignore_cert_check)
.build()?;
}
let mut req = client.request(method.clone(), url.to_string());
for (key, values) in headers.iter_all() {

View File

@ -400,7 +400,6 @@ async fn s3_tests() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let access_key = std::env::var("ACCESS_KEY")?;
let secret_key = std::env::var("SECRET_KEY")?;
let secure = std::env::var("ENABLE_HTTPS").is_ok();
let ignore_cert_check = std::env::var("IGNORE_CERT_CHECK").is_ok();
let region = std::env::var("SERVER_REGION").ok();
let mut burl = BaseUrl::from_string(host).unwrap();