From 8fe2e3daf3c4560bcf7158baede07cd9ef8d4f2a Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Tue, 3 Nov 2020 08:53:36 +0100 Subject: [PATCH] Add multipart form data params to json export --- packages/hurl/src/runner/log_serialize.rs | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/hurl/src/runner/log_serialize.rs b/packages/hurl/src/runner/log_serialize.rs index 9cc2cea31..0633728b4 100644 --- a/packages/hurl/src/runner/log_serialize.rs +++ b/packages/hurl/src/runner/log_serialize.rs @@ -101,6 +101,7 @@ impl Serialize for Request { state.serialize_field("queryString", &self.clone().querystring)?; state.serialize_field("headers", &self.clone().headers)?; state.serialize_field("cookies", &self.clone().cookies)?; + state.serialize_field("multipartFormData", &self.clone().multipart)?; if !self.clone().form.is_empty() { state.serialize_field("form", &self.clone().form)?; @@ -227,6 +228,34 @@ impl Serialize for Cookie { } } +impl Serialize for MultipartParam { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match &self.clone() { + MultipartParam::Param(param) => param.serialize(serializer), + MultipartParam::FileParam(file_param) => file_param.serialize(serializer), + } + } +} + +impl Serialize for FileParam { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut state = serializer.serialize_struct("FileParam", 4)?; + state.serialize_field("name", &self.clone().name)?; + if let Ok(s) = std::str::from_utf8(&self.clone().data) { + state.serialize_field("value", s)?; + } + state.serialize_field("fileName", &self.clone().filename)?; + state.serialize_field("contentType", &self.clone().content_type)?; + state.end() + } +} + impl Serialize for Value { fn serialize(&self, serializer: S) -> Result where