Skip to content

Commit

Permalink
Fix the boundary quotation, was using the wrong option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Mar 30, 2023
1 parent f2c3bc9 commit 9f77a1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/RestSharp/Request/RequestContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class RequestContent : IDisposable {

string GetContentTypeHeader(string contentType)
=> Content is MultipartFormDataContent
? $"{contentType}; boundary={GetBoundary(GetOrSetFormBoundary(), _request.MultipartFormQuoteParameters)}"
? $"{contentType}; boundary={GetBoundary(GetOrSetFormBoundary(), _request.MultipartFormQuoteBoundary)}"
: contentType;
}

Expand Down
10 changes: 8 additions & 2 deletions src/RestSharp/Request/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public RestRequest(Uri resource, Method method = Method.Get)
public bool AlwaysMultipartFormData { get; set; }

/// <summary>
/// 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).
/// </summary>
public bool MultipartFormQuoteParameters { get; set; } = true;
public bool MultipartFormQuoteParameters { get; set; }

/// <summary>
/// When set to true, the form boundary part of the content type will be enclosed in
/// quotation marks. Default is true.
/// </summary>
public bool MultipartFormQuoteBoundary { get; set; } = true;

/// <summary>
/// Overrides the default (random) form boundary
Expand Down
2 changes: 1 addition & 1 deletion test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static class RequestHandler {
var request = new RestRequest("/", Method.Post) { AlwaysMultipartFormData = true };

AddParameters(request);
request.MultipartFormQuoteParameters = false;
request.MultipartFormQuoteBoundary = false;

var response = await _client.ExecuteAsync(request);

Expand Down

0 comments on commit 9f77a1e

Please sign in to comment.