From cc35608430b47101255b93ae2f58dfd15e1297d3 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 20 Apr 2022 11:32:38 -0700 Subject: [PATCH] fix(core): do not serialize strings in http api form, closes #3910 (#3928) --- .changes/fix-form-serialization.md | 5 +++++ .changes/remove-form-part-file.md | 5 +++++ core/tauri/src/api/http.rs | 6 +----- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changes/fix-form-serialization.md create mode 100644 .changes/remove-form-part-file.md diff --git a/.changes/fix-form-serialization.md b/.changes/fix-form-serialization.md new file mode 100644 index 000000000..e0266c305 --- /dev/null +++ b/.changes/fix-form-serialization.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Fixes the HTTP API form text fields. diff --git a/.changes/remove-form-part-file.md b/.changes/remove-form-part-file.md new file mode 100644 index 000000000..b376394ec --- /dev/null +++ b/.changes/remove-form-part-file.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +**Breaking change:** Removed `tauri::api::http::FormPart::File`. diff --git a/core/tauri/src/api/http.rs b/core/tauri/src/api/http.rs index 820c27f5b..52bb41947 100644 --- a/core/tauri/src/api/http.rs +++ b/core/tauri/src/api/http.rs @@ -11,7 +11,7 @@ use serde_json::Value; use serde_repr::{Deserialize_repr, Serialize_repr}; use url::Url; -use std::{collections::HashMap, path::PathBuf, time::Duration}; +use std::{collections::HashMap, time::Duration}; /// The builder of [`Client`]. #[derive(Debug, Clone, Default, Deserialize)] @@ -129,7 +129,6 @@ impl Client { for (name, part) in form_body.0 { match part { FormPart::Bytes(bytes) => form.push((name, serde_json::to_string(&bytes)?)), - FormPart::File(file_path) => form.push((name, serde_json::to_string(&file_path)?)), FormPart::Text(text) => form.push((name, text)), } } @@ -176,7 +175,6 @@ impl Client { for (name, part) in form_body.0 { match part { FormPart::Bytes(bytes) => form.push((name, serde_json::to_string(&bytes)?)), - FormPart::File(file_path) => form.push((name, serde_json::to_string(&file_path)?)), FormPart::Text(text) => form.push((name, text)), } } @@ -222,8 +220,6 @@ pub enum ResponseType { #[serde(untagged)] #[non_exhaustive] pub enum FormPart { - /// A file path value. - File(PathBuf), /// A string value. Text(String), /// A byte array value.