Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multipart/form-data without a boundary

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?

like image 274
user2214387 Avatar asked May 12 '17 08:05

user2214387


1 Answers

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

like image 140
shaochuancs Avatar answered Sep 28 '22 08:09

shaochuancs