Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set User Agent Header for S3 Requests #2137

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
// limitations under the License.

use opendal::layers::LoggingLayer;
use opendal::raw::HttpClient;
use opendal::services::S3;
use opendal::Operator;
use reqwest::ClientBuilder;

use crate::errors::*;

Expand All @@ -29,6 +31,11 @@ impl S3Cache {
server_side_encryption: Option<bool>,
) -> Result<Operator> {
let mut builder = S3::default();
let user_agent = format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
let client_builder = ClientBuilder::new().user_agent(user_agent);
let client =
HttpClient::build(client_builder).map_err(|err| err.with_operation("S3::build"))?;
ajschmidt8 marked this conversation as resolved.
Show resolved Hide resolved
builder.http_client(client);
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
builder.bucket(bucket);
builder.root(key_prefix);

Expand Down
Loading