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?
1 Answer
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
1 Comment
multipart/form-data media type registry.