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

feat: set user agent in webdav requests #2284

Merged
merged 14 commits into from
Dec 3, 2024
Merged
2 changes: 1 addition & 1 deletion src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl S3Cache {
}

/// Set the user agent (helps with monitoring on the server side)
fn set_user_agent() -> HttpClient {
pub fn set_user_agent() -> HttpClient {
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
let user_agent = format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
let client_builder = ClientBuilder::new().user_agent(user_agent);
HttpClient::build(client_builder).unwrap()
Expand Down
4 changes: 3 additions & 1 deletion src/cache/webdav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::cache::s3::set_user_agent;
use crate::errors::*;
use opendal::layers::LoggingLayer;
use opendal::services::Webdav;
Expand All @@ -32,7 +33,8 @@ impl WebdavCache {
.root(key_prefix)
.username(username.unwrap_or_default())
.password(password.unwrap_or_default())
.token(token.unwrap_or_default());
.token(token.unwrap_or_default())
.http_client(set_user_agent());

let op = Operator::new(builder)?
.layer(LoggingLayer::default())
Expand Down