From 9f77a1e63ad8cd68e06c7c8023947d5249592b89 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Thu, 30 Mar 2023 17:13:01 +0200 Subject: [PATCH] Fix the boundary quotation, was using the wrong option --- src/RestSharp/Request/RequestContent.cs | 2 +- src/RestSharp/Request/RestRequest.cs | 10 ++++++++-- .../MultipartFormDataTests.cs | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/RestSharp/Request/RequestContent.cs b/src/RestSharp/Request/RequestContent.cs index 60669b9f5..1dfa7a7c8 100644 --- a/src/RestSharp/Request/RequestContent.cs +++ b/src/RestSharp/Request/RequestContent.cs @@ -203,7 +203,7 @@ void AddHeader(HeaderParameter parameter) { string GetContentTypeHeader(string contentType) => Content is MultipartFormDataContent - ? $"{contentType}; boundary={GetBoundary(GetOrSetFormBoundary(), _request.MultipartFormQuoteParameters)}" + ? $"{contentType}; boundary={GetBoundary(GetOrSetFormBoundary(), _request.MultipartFormQuoteBoundary)}" : contentType; } diff --git a/src/RestSharp/Request/RestRequest.cs b/src/RestSharp/Request/RestRequest.cs index bc102d0af..bf70b4f92 100644 --- a/src/RestSharp/Request/RestRequest.cs +++ b/src/RestSharp/Request/RestRequest.cs @@ -82,11 +82,17 @@ public RestRequest(Uri resource, Method method = Method.Get) public bool AlwaysMultipartFormData { get; set; } /// - /// When set to true, parameters in a multipart form data requests will be enclosed in + /// When set to true, parameter values in a multipart form data requests will be enclosed in /// quotation marks. Default is false. Enable it if the remote endpoint requires parameters /// to be in quotes (for example, FreshDesk API). /// - public bool MultipartFormQuoteParameters { get; set; } = true; + public bool MultipartFormQuoteParameters { get; set; } + + /// + /// When set to true, the form boundary part of the content type will be enclosed in + /// quotation marks. Default is true. + /// + public bool MultipartFormQuoteBoundary { get; set; } = true; /// /// Overrides the default (random) form boundary diff --git a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs index cd537881b..0004593da 100644 --- a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs +++ b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs @@ -83,7 +83,7 @@ public async Task MultipartFormData_NoBoundaryQuotes() { var request = new RestRequest("/", Method.Post) { AlwaysMultipartFormData = true }; AddParameters(request); - request.MultipartFormQuoteParameters = false; + request.MultipartFormQuoteBoundary = false; var response = await _client.ExecuteAsync(request);