Skip to content

Commit

Permalink
fix(services/gcs): Remove HOST header to avoid gcs RESET connection (#…
Browse files Browse the repository at this point in the history
…2139)

fix(services/gcs): Remove HOST header to avoid gcs RESET

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Apr 26, 2023
1 parent d3be656 commit 2f5e31d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/service_test_gcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion core/src/services/gcs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <https://github.com/seanmonstar/reqwest/issues/1809>,
// 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,
Expand Down

0 comments on commit 2f5e31d

Please sign in to comment.