Maximum length of a MIME Content-Type header field?

前端 未结 3 500
野性不改
野性不改 2020-12-30 19:18

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\", \"audi

相关标签:
3条回答
  • 2020-12-30 19:41

    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://tools.ietf.org/html/rfc6838#section-4.2

    0 讨论(0)
  • 2020-12-30 19:44

    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.

    0 讨论(0)
  • 2020-12-30 19:48

    We run an SaaS system that allows users to upload files. We'd originally designed it to store MIME Types up to 50 characters. In the last several days we've seen several attempts to upload 71-bytes types. So, we're changing to 250. 100 seemed "good" but it's only a few more than the max we're seeing now. 500 seems silly, so 250 is the selected one.

    0 讨论(0)
提交回复
热议问题