How is character encoding specified in a multipart/form-data HTTP POST request?
<p>The HTML 5 specification describes an <a href="http://www.w3.org/TR/2014/REC-html5-20141028/forms.html#multipart-form-data" rel="nofollow noreferrer">algorithm</a> for selecting the character encoding to be used in a multi-part form submission (e.g. UTF-8). However, it is not clear how the selected encoding should be relayed to the server so that the content can be properly decoded on the receiving end.</p>
<p>Often, character encodings are represented by appending a &quot;charset&quot; parameter to the value of the <code>Content-Type</code> request header. However, this parameter does not appear to be defined for the <code>multipart/form-data</code> MIME type:</p>
<p><a href="https://www.rfc-editor.org/rfc/rfc7578#section-8" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc7578#section-8</a></p>
<p>Each part in a multipart form submission may provide its own <code>Content-Type</code> header; however, RFC 7578 notes that &quot;in practice, many widely deployed implementations do not supply a charset parameter in each part, but rather, they rely on the notion of a 'default charset' for a multipart/form-data instance&quot;.</p>
<p>RFC 7578 goes on to suggest that a hidden &quot;_charset_&quot; form field can be used for this purpose. However, neither Safari (9.1) nor Chrome (51) appear to populate this field, nor do they provide any per-part encoding information.</p>
<p>I've looked at the request headers produced by both browsers and I don't see any obvious character encoding information. Does anyone know how the browsers are conveying this information to the server?</p>