6

Is a multipart/form-data request valid without a boundary? According to the specification when there are more than 1 parts then boundary is used to separate them(and this boundary should not be part of the body). I have a request where there is a single body as a raw content or a file and in the content-type we pass "multipart/form-data" . Is this kind of request actually valid?

user2214387
  • 61
  • 1
  • 3

1 Answers1

10

I think multipart/form-data request without a boundary is invalid.

According to RFC7231, request with only 1 part is still valid multipart MIME type and should follow multipart MIME rules:

MIME provides for a number of "multipart" types -- encapsulations of one or more representations within a single message body. All multipart types share a common syntax ... and include a boundary parameter as part of the media type value.

According to RFC2046, "boundary" is required and mandatory:

The Content-Type field for multipart entities requires one parameter, "boundary".

...

The only mandatory global parameter for the "multipart" media type is the boundary parameter

Community
  • 1
  • 1
shaochuancs
  • 15,342
  • 3
  • 54
  • 62
  • FYI: This is also conclusive with the [`multipart/form-data` media type registry](https://www.iana.org/assignments/media-types/multipart/form-data). – DaSourcerer May 13 '17 at 01:24