Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MIME] Missing possibility to create DataPart with binary encoding #60301

Open
@cpernot-hf

Description

@cpernot-hf

Symfony version(s) affected

6.4.17

Description

When creating a DataPart object, $encoding parameter is limited to 'quoted-printable', 'base64' or '8bit' by this code in TextPart.php:

if ('quoted-printable' !== $encoding && 'base64' !== $encoding && '8bit' !== $encoding) {
    throw new InvalidArgumentException(sprintf('The encoding must be one of "quoted-printable", "base64", or "8bit" ("%s" given).', $encoding));
}

We are missing the possiblity to set a binary encoding to create OData batch request, as each part must have a binary encoding (https://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398359) : A MIME part representing an individual request MUST include a Content-Type header with value application/http and a Content-Transfer-Encoding header with value binary.

From MIME RFC1341 (https://www.w3.org/Protocols/rfc1341/5_Content-Transfer-Encoding.html) it seems binary is just like 8bit, but without any line-length limit.

How to reproduce

new DataPart($bodyAsString, null, 'application/http', 'binary');

throws the above exception

InvalidArgumentException('The encoding must be one of "quoted-printable", "base64", or "8bit" ("binary" given).');

Possible Solution

Maybe it's possible to treat "binary" as an alias of "8bit"

Additional Context

No response

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