From f0a91783f340ca00ac4b561b0e8a1fdcb0039f5e Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 27 Apr 2023 00:09:25 +0800 Subject: [PATCH] fix(services/gcs): Remove HOST header to avoid gcs RESET Signed-off-by: Xuanwo --- .github/workflows/service_test_gcs.yml | 5 +---- core/src/services/gcs/backend.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/service_test_gcs.yml b/.github/workflows/service_test_gcs.yml index 9ec3adf012ab..40838834c0be 100644 --- a/.github/workflows/service_test_gcs.yml +++ b/.github/workflows/service_test_gcs.yml @@ -47,10 +47,7 @@ jobs: - name: Test shell: bash working-directory: core - # Workaround - # gcs presign test failed for https://github.com/apache/incubator-opendal/issues/2125 - # We should remove this feature until the issue is fixed. - run: cargo test gcs --features=native-tls -- --show-output + run: cargo test gcs -- --show-output env: RUST_BACKTRACE: full RUST_LOG: debug diff --git a/core/src/services/gcs/backend.rs b/core/src/services/gcs/backend.rs index ce4eb5636c98..5d01a534e9b1 100644 --- a/core/src/services/gcs/backend.rs +++ b/core/src/services/gcs/backend.rs @@ -21,6 +21,7 @@ use std::fmt::Formatter; use std::sync::Arc; use async_trait::async_trait; +use http::header::HOST; use http::StatusCode; use log::debug; use reqsign::GoogleCredentialLoader; @@ -544,7 +545,14 @@ impl Accessor for GcsBackend { self.core.sign_query(&mut req, args.expire()).await?; // We don't need this request anymore, consume it directly. - let (parts, _) = req.into_parts(); + let (mut parts, _) = req.into_parts(); + // Always remove host header, let users' client to set it based on HTTP + // version. + // + // As discussed in , + // google server could send RST_STREAM of PROTOCOL_ERROR if our request + // contains host header. + parts.headers.remove(HOST); Ok(RpPresign::new(PresignedRequest::new( parts.method,