Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum length of a MIME Content-Type header field?

Tags:

email

mime

I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc).

Does anybody know the maximum length that I can expect a content-type to be?

like image 713
Ian Nelson Avatar asked Aug 21 '08 13:08

Ian Nelson


People also ask

What is the longest MIME type?

According to RFC 4288 "Media Type Specifications and Registration Procedures", type (eg. "application") and subtype (eg "vnd...") both can be max 127 characters. So including the slash, the maximum length is 255.

What is MIME type in HTML?

A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

What is a MIME type file?

A media type (also known as a MIME type) is a two-part identifier for file formats and format contents transmitted on the Internet. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications.

What is MIME type in Javascript?

MIME (Multipurpose Internet Mail Extensions) type is a standard way of describing a data type in the body of an HTTP message or email. The MIME type is passed in the Content-Type header. For example, the Content-Type: text/html header tells the browser that it received an HTML page.


2 Answers

I hope I havn't misread, but it looks like the length is max 127/127 or 255 total.

RFC 4288 has a reference in 4.2 (page 6):

Type and subtype names MUST conform to the following ABNF:     type-name = reg-name    subtype-name = reg-name     reg-name = 1*127reg-name-chars    reg-name-chars = ALPHA / DIGIT / "!" /                    "#" / "$" / "&" / "." /                    "+" / "-" / "^" / "_" 

It is not clear to me if the +suffix can add past the 127, but it appears not.

like image 175
speaker Avatar answered Sep 26 '22 17:09

speaker


In RFC 6838 which is latest standard and obsoletes RFC4288, there is a following statement.

"Also note that while this syntax allows names of up to 127 characters, implementation limits may make such long names problematic. For this reason, <type-name> and <subtype-name> SHOULD be limited to 64 characters."

64+1+64 = 129.

But I suspect the standard should mean 63+1+63=127.

link: https://www.rfc-editor.org/rfc/rfc6838#section-4.2

like image 39
appleleaf Avatar answered Sep 25 '22 17:09

appleleaf