Skip to content

Double quotes option for multipart/form-data boundary #2011

Closed

Description

@Coolava

I tried migration 104 to 108.

But since version 107, System.net.http is used for Http Request. It makes difference.

When upload file using multipart/form-data, AddFiles called.
And it makes MultipartFormDataContent and pass boundary to parameter.

void AddFiles() {
if (!_request.HasFiles() && !_request.AlwaysMultipartFormData) return;
var mpContent = new MultipartFormDataContent(GetOrSetFormBoundary());

Also this is :

? $"{contentType}; boundary=\"{GetOrSetFormBoundary()}\""

When MultipartFormDataContent created the boundary parameter will always wrapped "(double quotes).

boundary will like this in version 107 :

boundary="gc0pJq0M8jU534c0p"

But in version 104 :

boundary=gc0pJq0M8jU534c0p

There is no double quotes.
According to RFC 2046 double quotes is selective option.

How about add new option in RestSharp for double quotes?

Activity

  1. alexeyzimarev commented on Mar 12, 2023

    @alexeyzimarev
    Member

    The option already exists, but it wasn't applied in that case.

  2. alexeyzimarev commented on Mar 12, 2023

    @alexeyzimarev
    Member

    I am wrong, the option is to use quotes around parameter names, sorry.

  3. alexeyzimarev commented on Mar 30, 2023

    @alexeyzimarev
    Member

    I was able to fix it when the content type header is added manually to the request using AddHeader. But when the constructor of MultipartFormDataContent is called, RestSharp provides it with the boundary without quotes, and here what happens in .NET code:

                string quotedBoundary = boundary;
                if (!quotedBoundary.StartsWith('\"'))
                {
                    quotedBoundary = "\"" + quotedBoundary + "\"";
                }

    I made a change to re-create the content type header to work around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions