From 5cc69d272aea31fc016d638beba7e1a5240d2174 Mon Sep 17 00:00:00 2001 From: Ashe Date: Wed, 3 Jun 2020 16:35:23 -0500 Subject: [PATCH] fix SerializeType.MULTIPART_FROM_DATA name "FROM" != "FORM" --- src/DSharp4Webhook.Rest.Mono/MonoProvider.cs | 2 +- src/DSharp4Webhook/Rest/DefaultProvider.cs | 2 +- src/DSharp4Webhook/Serialization/SerializeContext.cs | 8 ++++---- src/DSharp4Webhook/Serialization/SerializeType.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DSharp4Webhook.Rest.Mono/MonoProvider.cs b/src/DSharp4Webhook.Rest.Mono/MonoProvider.cs index e248d31..33a514a 100644 --- a/src/DSharp4Webhook.Rest.Mono/MonoProvider.cs +++ b/src/DSharp4Webhook.Rest.Mono/MonoProvider.cs @@ -125,7 +125,7 @@ private void PrepareRequest(HttpWebRequest request, Stream requestStream, Serial requestStream.Write(context.Content, 0, context.Content.Length); break; } - case SerializeType.MULTIPART_FROM_DATA: + case SerializeType.MULTIPART_FORM_DATA: { MultipartHelper.PrepareMultipartFormDataRequest(request, requestStream, context); break; diff --git a/src/DSharp4Webhook/Rest/DefaultProvider.cs b/src/DSharp4Webhook/Rest/DefaultProvider.cs index 3008014..91b5024 100644 --- a/src/DSharp4Webhook/Rest/DefaultProvider.cs +++ b/src/DSharp4Webhook/Rest/DefaultProvider.cs @@ -113,7 +113,7 @@ private void PrepareContent(HttpRequestMessage requestMessage, SerializeContext break; } - case SerializeType.MULTIPART_FROM_DATA: + case SerializeType.MULTIPART_FORM_DATA: { var multipartContent = new MultipartFormDataContent(); if (!(data.Files is null) && data.Files.Keys.Count != 0) diff --git a/src/DSharp4Webhook/Serialization/SerializeContext.cs b/src/DSharp4Webhook/Serialization/SerializeContext.cs index 029e894..e28c27c 100644 --- a/src/DSharp4Webhook/Serialization/SerializeContext.cs +++ b/src/DSharp4Webhook/Serialization/SerializeContext.cs @@ -60,7 +60,7 @@ public SerializeContext(byte[]? content, byte[]? data, string? fileName = null) if (!(data is null)) { - Type = SerializeType.MULTIPART_FROM_DATA; + Type = SerializeType.MULTIPART_FORM_DATA; #pragma warning disable CS8604 // Possible null reference argument. Files = new Dictionary { [fileName] = data }; #pragma warning restore CS8604 // Possible null reference argument. @@ -80,7 +80,7 @@ public SerializeContext(byte[]? content, byte[]? data, string? fileName = null) public SerializeContext(byte[]? content, Dictionary? files = null) #nullable restore { - Type = files is null || (files?.Count ?? 0) < 1 ? SerializeType.APPLICATION_JSON : SerializeType.MULTIPART_FROM_DATA; + Type = files is null || (files?.Count ?? 0) < 1 ? SerializeType.APPLICATION_JSON : SerializeType.MULTIPART_FORM_DATA; Content = content; Files = files; } @@ -129,7 +129,7 @@ public SerializeContext(byte[] data, string? fileName = null) Checks.CheckForNull(data, nameof(data)); fileName = string.IsNullOrWhiteSpace(fileName) ? Guid.NewGuid().ToString() : fileName; - Type = SerializeType.MULTIPART_FROM_DATA; + Type = SerializeType.MULTIPART_FORM_DATA; #pragma warning disable CS8604 // Possible null reference argument. Files = new Dictionary { [fileName] = data }; #pragma warning restore CS8604 // Possible null reference argument. @@ -161,7 +161,7 @@ public void AddFile(byte[] data, string? fileName = null) { Files = new Dictionary(); // The format changes when a new file is added - Type = SerializeType.MULTIPART_FROM_DATA; + Type = SerializeType.MULTIPART_FORM_DATA; } // Setting the value forcibly even if it exists #pragma warning disable CS8604 // Possible null reference argument. diff --git a/src/DSharp4Webhook/Serialization/SerializeType.cs b/src/DSharp4Webhook/Serialization/SerializeType.cs index 99b51b1..41f873a 100644 --- a/src/DSharp4Webhook/Serialization/SerializeType.cs +++ b/src/DSharp4Webhook/Serialization/SerializeType.cs @@ -7,7 +7,7 @@ namespace DSharp4Webhook.Serialization /// public enum SerializeType { - MULTIPART_FROM_DATA, + MULTIPART_FORM_DATA, APPLICATION_JSON } @@ -22,7 +22,7 @@ public static string Convert(SerializeType type) { case SerializeType.APPLICATION_JSON: return "application/json"; - case SerializeType.MULTIPART_FROM_DATA: + case SerializeType.MULTIPART_FORM_DATA: return "multipart/form-data"; }