Skip to content

v3.2: How to use style with multipart (and headers/cookies?) [percent-encoding issues] #4798

@handrews

Description

@handrews

It seems that in 3.1, we expanded the use of the Encoding Object's style/explode/ allowReserved fields to multipart/form-data, when previously they only applied to application/x-www-form-urlencoded. This was done in PR #2066.

However, these fields are based on RFC6570 and apply URI percent-encoding to both the names and the values of form fields. While it's clear enough how to convert from the name=value&name=value to putting names in the Content-Disposition and values in the part bodies, it is rarely the case that percent-encoding is appropriate. But we do not call attention to that.

Currently (3.1.1) the only thing we say about this is in Appendix E.2, where we note that:

The form-data media type allows arbitrary text or binary data in its parts, so percent-encoding is not needed and is likely to cause interoperability problems unless the Content-Type of the part is defined to require it.

But we do not point out that style automatically applies percent-encoding.

What was the intention here? AFAICT, you would almost never want to use these fields unless you are doing something very specific that was guaranteed to not trigger any percent-encoding. It's not even entirely clear to me how binary parts would work.

I feel like we should give some implementation guidance here, but my personal advice would be "don't, this is a footgun you don't want to touch."

Metadata

Metadata

Assignees

Labels

headersmedia and encodingIssues regarding media type support and how to encode data (outside of query/path params)param serializationIssues related to parameter and/or header serialization

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions