diff --git a/bundle.json b/bundle.json index 7eb45424912e54a5bba7381a29bf8d784fade2d9..1c774d29a92873db3f67c014a8345165e9be45f9 100644 --- a/bundle.json +++ b/bundle.json @@ -8,15 +8,20 @@ "ram": "~200KB", "deps": { "third_party": [ - "//third_party/rust/crates/tokio/tokio:lib", - "//third_party/rust/crates/libc:lib", - "//third_party/openssl:libcrypto_shared", - "//third_party/openssl:libssl_shared" - ] + "openssl", + "rust_tokio" + ] }, "build": { "sub_component": [], "inner_kits": [ + { + "header": { + "header_base": [], + "header_files": [] + }, + "name": "//commonlibrary/rust/ylong_http/ylong_http_client_inner:ylong_http_client_rlib" + }, { "header": { "header_base": [], diff --git a/patches/build.patch b/patches/build.patch new file mode 100644 index 0000000000000000000000000000000000000000..992f93a0f36f5aa88a1b6c49fdc199f2771badb0 --- /dev/null +++ b/patches/build.patch @@ -0,0 +1,21 @@ +diff --git a/compile_standard_whitelist.json b/compile_standard_whitelist.json +index 48644d6..58e0d85 100644 +--- a/compile_standard_whitelist.json ++++ b/compile_standard_whitelist.json +@@ -1054,7 +1054,8 @@ + "//foundation/communication/netstack/frameworks/js/napi/http:http", + "//foundation/communication/netstack/utils/napi_utils:napi_utils", + "//foundation/communication/netstack/utils/napi_utils:napi_utils_static", +- "//foundation/communication/wifi/wifi/services/wifi_standard/ipc_framework/cRPC:crpc_client", ++ "//foundation/communication/netstack/interfaces/innerkits/rust/ylong_http_client:ylong_http_client", ++ "//foundation/communication/wifi/wifi/services/wifi_standard/ipc_framework/cRPC:crpc_client", + "//foundation/communication/wifi/wifi/services/wifi_standard/ipc_framework/cRPC:crpc_server", + "//foundation/communication/wifi/wifi/services/wifi_standard/wifi_framework/wifi_manage:wifi_manager_service", + "//foundation/communication/wifi/wifi/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit", +@@ -3248,4 +3249,4 @@ + "//third_party/wpa_supplicant/wpa_supplicant-2.9_standard:wpa", + "//third_party/wpa_supplicant/wpa_supplicant-2.9_standard:wpa_updater" + ] +-} +\ No newline at end of file ++} diff --git a/patches/netstack.patch b/patches/netstack.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7166672e95fc09255186172298fa41cfc7a86a8 --- /dev/null +++ b/patches/netstack.patch @@ -0,0 +1,30 @@ +diff --git a/interfaces/innerkits/rust/ylong_http_client/BUILD.gn b/interfaces/innerkits/rust/ylong_http_client/BUILD.gn +index d430831..8817685 100644 +--- a/interfaces/innerkits/rust/ylong_http_client/BUILD.gn ++++ b/interfaces/innerkits/rust/ylong_http_client/BUILD.gn +@@ -26,12 +26,10 @@ ohos_rust_shared_library("ylong_http_client") { + edition = "2021" + clippy_lints = "none" + deps = [ +- "//third_party/rust/crates/reqwest:lib", +- "//third_party/rust/crates/tokio/tokio:lib", +- "//third_party/rust/crates/tokio/tokio-util:lib", ++ "//commonlibrary/rust/ylong_http/ylong_http_client:ylong_http_client_rlib" + ] + features = [ + "default", +- "reqwest_impl", ++ "ylong_impl", + ] + } +diff --git a/interfaces/innerkits/rust/ylong_http_client/src/lib.rs b/interfaces/innerkits/rust/ylong_http_client/src/lib.rs +index 0b57b50..3759fdb 100644 +--- a/interfaces/innerkits/rust/ylong_http_client/src/lib.rs ++++ b/interfaces/innerkits/rust/ylong_http_client/src/lib.rs +@@ -21,3 +21,6 @@ mod reqwest_impl; + + #[cfg(feature = "reqwest_impl")] + pub use reqwest_impl::*; ++ ++#[cfg(feature = "ylong_impl")] ++pub use ylong_http_client_inner::*; diff --git a/patches/patches.json b/patches/patches.json new file mode 100644 index 0000000000000000000000000000000000000000..58b84b3c82bd4c2c8ae6fe2990bbcf466a8bcfb6 --- /dev/null +++ b/patches/patches.json @@ -0,0 +1,14 @@ +{ + "patches": [ + { + "project":"build", + "patch_file":"build.patch", + "path":"build" + }, + { + "project":"netstack", + "patch_file":"netstack.patch", + "path":"foundation/communication/netstack" + } + ] +} \ No newline at end of file diff --git a/ylong_http/BUILD.gn b/ylong_http/BUILD.gn index 8b9d6bb81176fc338de97560e9878a6bd41bb293..0fb5f926bdb4db3bacfe1ff3e88a865a4dbfecf5 100644 --- a/ylong_http/BUILD.gn +++ b/ylong_http/BUILD.gn @@ -23,9 +23,9 @@ ohos_rust_static_library("lib") { sources = [ "src/lib.rs" ] deps = [ "//third_party/rust/crates/tokio/tokio:lib" ] - clippy_lints = "none" features = [ "default", "http1_1", + "tokio_base", ] } diff --git a/ylong_http/src/headers.rs b/ylong_http/src/headers.rs index 9e672c6ae9dc609d1908457cbc6ab0311a51f5d9..51de404207205e3257e3105d7d85bb0244aeddd0 100644 --- a/ylong_http/src/headers.rs +++ b/ylong_http/src/headers.rs @@ -562,7 +562,7 @@ impl fmt::Display for Headers { "{}: {}", k.to_string(), v.to_str() - .unwrap_or("".to_string()) + .unwrap_or_else(|_| "".to_string()) )?; } Ok(()) diff --git a/ylong_http_client/BUILD.gn b/ylong_http_client/BUILD.gn index 02e7c6b7a02dce87e813d837300d6a2780cacf69..ccc1812d38452995e46dcc1b7e361e9ea7a43ec3 100644 --- a/ylong_http_client/BUILD.gn +++ b/ylong_http_client/BUILD.gn @@ -14,6 +14,33 @@ import("//build/ohos.gni") import("//build/test.gni") +ohos_rust_static_library("ylong_http_client_rlib") { + crate_name = "ylong_http_client_inner" + crate_type = "rlib" + crate_root = "src/lib.rs" + + subsystem_name = "commonlibrary" + part_name = "ylong_http" + + sources = [ "src/lib.rs" ] + deps = [ + "//commonlibrary/rust/ylong_http/ylong_http:lib", + "//third_party/openssl:libcrypto_shared", + "//third_party/openssl:libssl_shared", + "//third_party/rust/crates/libc:lib", + "//third_party/rust/crates/tokio/tokio:lib", + ] + features = [ + "default", + "async", + "http1_1", + "c_openssl_3_0", + "__tls", + "__c_openssl", + "tokio_base", + ] +} + ohos_rust_shared_library("ylong_http_client") { crate_name = "ylong_http_client" crate_type = "dylib" @@ -30,7 +57,6 @@ ohos_rust_shared_library("ylong_http_client") { "//third_party/rust/crates/libc:lib", "//third_party/rust/crates/tokio/tokio:lib", ] - clippy_lints = "none" features = [ "default", "async", @@ -53,7 +79,6 @@ ohos_rust_unittest("rust_ylong_http_client_unit_test") { "//third_party/rust/crates/libc:lib", "//third_party/rust/crates/tokio/tokio:lib", ] - clippy_lints = "none" rustflags = [ "--cfg=feature=\"default\"", diff --git a/ylong_http_client/src/util/redirect.rs b/ylong_http_client/src/util/redirect.rs index 4b8f64b11cc21bba203cf7bef0def5d66d85ed94..917e2ca5d8fdcba9b31a36f325e211e23912acad 100644 --- a/ylong_http_client/src/util/redirect.rs +++ b/ylong_http_client/src/util/redirect.rs @@ -145,7 +145,7 @@ impl Redirect { let origin_scheme = request .uri() .scheme() - .ok_or(HttpClientError::new_with_message( + .ok_or_else(|| HttpClientError::new_with_message( ErrorKind::Connect, "No uri scheme in request", ))? @@ -153,7 +153,7 @@ impl Redirect { let auth = request .uri() .authority() - .ok_or(HttpClientError::new_with_message( + .ok_or_else(|| HttpClientError::new_with_message( ErrorKind::Connect, "No uri authority in request", ))? @@ -166,7 +166,7 @@ impl Redirect { .path( loc_uri .path() - .ok_or(HttpClientError::new_with_message( + .ok_or_else(|| HttpClientError::new_with_message( ErrorKind::Connect, "No loc_uri path in location", ))? @@ -175,7 +175,7 @@ impl Redirect { .query( loc_uri .query() - .ok_or(HttpClientError::new_with_message( + .ok_or_else(|| HttpClientError::new_with_message( ErrorKind::Connect, "No loc_uri query in location", ))?