This is an automated email from the ASF dual-hosted git repository.
koushiro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new aa212e107 feat(services/http): Add https as alias for http scheme
(#7241)
aa212e107 is described below
commit aa212e107907284dd9a9fb2a75be019db2eafb29
Author: Chris Barnes <[email protected]>
AuthorDate: Fri Mar 13 06:30:57 2026 +0000
feat(services/http): Add https as alias for http scheme (#7241)
* Add https as alias for http scheme
* Test that Operator::from_uri("http...") works
* fmt
---
core/services/http/src/config.rs | 31 +++++++++++++++++++++++++++++++
core/services/http/src/lib.rs | 4 ++++
2 files changed, 35 insertions(+)
diff --git a/core/services/http/src/config.rs b/core/services/http/src/config.rs
index 4e5578920..77a62fc69 100644
--- a/core/services/http/src/config.rs
+++ b/core/services/http/src/config.rs
@@ -76,8 +76,17 @@ impl opendal_core::Configurator for HttpConfig {
mod tests {
use super::*;
use opendal_core::Configurator;
+ use opendal_core::Operator;
use opendal_core::OperatorUri;
+ fn register_http() {
+ let once = std::sync::Once::new();
+ once.call_once(|| {
+ let registry = opendal_core::OperatorRegistry::get();
+ crate::register_http_service(registry);
+ });
+ }
+
#[test]
fn from_uri_sets_endpoint_and_root() {
let uri = OperatorUri::new(
@@ -126,4 +135,26 @@ mod tests {
assert_eq!(cfg.endpoint.as_deref(), Some("http://example.com"));
}
+
+ #[test]
+ fn operator_from_uri_http() {
+ register_http();
+ let op = Operator::from_uri("http://example.com").unwrap();
+ assert_eq!(op.info().scheme(), "http");
+ }
+
+ #[test]
+ fn operator_from_uri_https() {
+ register_http();
+ let op = Operator::from_uri("https://example.com").unwrap();
+ assert_eq!(op.info().scheme(), "http");
+ }
+
+ #[test]
+ fn from_uri_with_https_scheme() {
+ // "https" is an alias for "http" to support standard https:// URIs
+ let uri = OperatorUri::new("https://example.com", Vec::<(String,
String)>::new()).unwrap();
+ let cfg = HttpConfig::from_uri(&uri).unwrap();
+ assert_eq!(cfg.endpoint.as_deref(), Some("https://example.com"));
+ }
}
diff --git a/core/services/http/src/lib.rs b/core/services/http/src/lib.rs
index f9a24dcc0..a97a8a9c8 100644
--- a/core/services/http/src/lib.rs
+++ b/core/services/http/src/lib.rs
@@ -30,7 +30,11 @@ pub use config::HttpConfig;
/// Default scheme for http service.
pub const HTTP_SCHEME: &str = "http";
+/// Alias for http service scheme for https connections.
+pub const HTTPS_SCHEME: &str = "https";
+
/// Register this service into the given registry.
pub fn register_http_service(registry: &opendal_core::OperatorRegistry) {
registry.register::<Http>(HTTP_SCHEME);
+ registry.register::<Http>(HTTPS_SCHEME);
}