Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which separator should be used in the Content-Type header for a multipart data request? Comma or Semicolon?

Should the Content-Type header in a REST API web request be formatted with a comma as in RFC 1867:

Content-type: multipart/form-data, boundary=AaB03x

Or with a semicolon, as in RFC 1049 and RFC 2045:

Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p
like image 468
WW. Avatar asked Mar 03 '16 01:03

WW.


2 Answers

It's really all just a simple mistake and the ; is correct.

RFC 1867 was an experimental definition. All subsequent definitions have corrected this mistake. For example:

  • RFC 2388 explicitly replaces 1867 and refers to HTML 40 for the (correct) definition of the separator.
  • RFC 7231 explicitly refers to 2388 as the definition to use in HTTP/1.1.

And finally... there is also an official correction to RFC 1867 to make it use the correct delimiter.

like image 101
Peter Brittain Avatar answered Oct 14 '22 02:10

Peter Brittain


Rely on the newest RFC: 7231, section 3.1.1.1 says:

media-type = type "/" subtype *( OWS ";" OWS parameter )

This leaves no room for interpretations or custom formats.

like image 43
Michael-O Avatar answered Oct 14 '22 01:10

Michael-O