diff --git a/debian/control b/debian/control index 992bf264..3f513cdf 100644 --- a/debian/control +++ b/debian/control @@ -47,10 +47,10 @@ Build-Depends: debhelper (>= 12), librust-proxmox-borrow-1+default-dev, librust-proxmox-compression-0.1+default-dev (>= 0.1.1-~~), librust-proxmox-fuse-0.1+default-dev (>= 0.1.3-~~), - librust-proxmox-http-0.6+client-dev (>= 0.6.1-~~), - librust-proxmox-http-0.6+default-dev (>= 0.6.1-~~), - librust-proxmox-http-0.6+http-helpers-dev (>= 0.6.1-~~), - librust-proxmox-http-0.6+websocket-dev (>= 0.6.1-~~), + librust-proxmox-http-0.6+client-dev (>= 0.6.3-~~), + librust-proxmox-http-0.6+default-dev (>= 0.6.3-~~), + librust-proxmox-http-0.6+http-helpers-dev (>= 0.6.3-~~), + librust-proxmox-http-0.6+websocket-dev (>= 0.6.3-~~), librust-proxmox-io-1+default-dev (>= 1.0.1-~~), librust-proxmox-io-1+tokio-dev (>= 1.0.1-~~), librust-proxmox-lang-1+default-dev (>= 1.1-~~), diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml index 40e34f9a..6bc02ecd 100644 --- a/pbs-client/Cargo.toml +++ b/pbs-client/Cargo.toml @@ -36,7 +36,7 @@ pathpatterns = "0.1.2" proxmox-async = "0.4" proxmox-compression = "0.1.1" proxmox-fuse = "0.1.3" -proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] } +proxmox-http = { version = "0.6.3", features = [ "client", "http-helpers", "websocket" ] } proxmox-io = { version = "1.0.1", features = [ "tokio" ] } proxmox-lang = "1.1" proxmox-router = { version = "1.2.4", features = [ "cli" ] } diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs index 6d5d9ad5..4ef1350b 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -23,11 +23,10 @@ use proxmox_sys::linux::tty; use proxmox_async::broadcast_future::BroadcastFuture; use proxmox_http::client::{HttpsConnector, RateLimiter}; -use proxmox_http::uri::build_authority; +use proxmox_http::uri::{build_authority, json_object_to_query}; use pbs_api_types::percent_encoding::DEFAULT_ENCODE_SET; use pbs_api_types::{Authid, RateLimitConfig, Userid}; -use pbs_tools::json::json_object_to_query; use pbs_tools::ticket; use super::pipe_to_stream::PipeToSendStream; diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs index 75c5ba32..50e76a49 100644 --- a/pbs-client/src/tools/mod.rs +++ b/pbs-client/src/tools/mod.rs @@ -10,12 +10,12 @@ use anyhow::{bail, format_err, Context, Error}; use serde_json::{json, Value}; use xdg::BaseDirectories; +use proxmox_http::uri::json_object_to_query; use proxmox_router::cli::{complete_file_name, shellword_split}; use proxmox_schema::*; use proxmox_sys::fs::file_get_json; use pbs_api_types::{Authid, BackupNamespace, RateLimitConfig, UserWithTokens, BACKUP_REPO_URL}; -use pbs_tools::json::json_object_to_query; use crate::{BackupRepository, HttpClient, HttpClientOptions}; diff --git a/pbs-client/src/vsock_client.rs b/pbs-client/src/vsock_client.rs index 57a46d57..6d62cd93 100644 --- a/pbs-client/src/vsock_client.rs +++ b/pbs-client/src/vsock_client.rs @@ -13,6 +13,7 @@ use serde_json::Value; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf}; use tokio::net::UnixStream; +use proxmox_http::uri::json_object_to_query; use proxmox_router::HttpError; pub const DEFAULT_VSOCK_PORT: u16 = 807; @@ -240,7 +241,7 @@ impl VsockClient { let request = builder.body(Body::from(data.to_string()))?; return Ok(request); } else { - let query = pbs_tools::json::json_object_to_query(data)?; + let query = json_object_to_query(data)?; let url: Uri = format!("vsock://{}:{}/{}?{}", self.cid, self.port, path, query).parse()?; let builder = make_builder("application/x-www-form-urlencoded", &url); diff --git a/pbs-tools/src/json.rs b/pbs-tools/src/json.rs index 89706e79..d2a5b82d 100644 --- a/pbs-tools/src/json.rs +++ b/pbs-tools/src/json.rs @@ -1,47 +1,5 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{bail, Error}; use serde_json::Value; -pub fn json_object_to_query(data: Value) -> Result { - let mut query = url::form_urlencoded::Serializer::new(String::new()); - - let object = data.as_object().ok_or_else(|| { - format_err!("json_object_to_query: got wrong data type (expected object).") - })?; - - for (key, value) in object { - match value { - Value::Bool(b) => { - query.append_pair(key, &b.to_string()); - } - Value::Number(n) => { - query.append_pair(key, &n.to_string()); - } - Value::String(s) => { - query.append_pair(key, s); - } - Value::Array(arr) => { - for element in arr { - match element { - Value::Bool(b) => { - query.append_pair(key, &b.to_string()); - } - Value::Number(n) => { - query.append_pair(key, &n.to_string()); - } - Value::String(s) => { - query.append_pair(key, s); - } - _ => bail!( - "json_object_to_query: unable to handle complex array data types." - ), - } - } - } - _ => bail!("json_object_to_query: unable to handle complex data types."), - } - } - - Ok(query.finish()) -} pub fn required_string_param<'a>(param: &'a Value, name: &str) -> Result<&'a str, Error> { match param[name].as_str() { diff --git a/src/tools/subscription.rs b/src/tools/subscription.rs index 14b95f30..0cc112dc 100644 --- a/src/tools/subscription.rs +++ b/src/tools/subscription.rs @@ -7,10 +7,9 @@ use serde_json::json; use proxmox_schema::api; use proxmox_http::client::SimpleHttp; +use proxmox_http::uri::json_object_to_query; use proxmox_sys::fs::{replace_file, CreateOptions}; -use pbs_tools::json::json_object_to_query; - use crate::config::node; use crate::tools::{self, pbs_simple_http};