MIME Con​​tent-Type标头字段的最大长度?

时间:2021-02-07 22:19:33

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).

我只是设计一个数据库表的模式,它将保存电子邮件附件的详细信息 - 它们的大小以字节,文件名和内容类型(即“image / jpg”,“audio / mp3”等)。

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

有人知道我可以期待内容类型的最大长度吗?

3 个解决方案

#1


43  

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

我希望我不会误读,但看起来长度最多为127/127或255。

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

RFC 4288在4.2(第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.

我不清楚+后缀是否可以添加超过127,但似乎没有。

#2


5  

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

在RFC 6838(最新标准和废弃RFC4288)中,有以下声明。

"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."

“另请注意,虽然此语法允许最多127个字符的名称,但实现限制可能会使这些长名称出现问题。因此, 应限制为64个字符。”

64+1+64 = 129.

64 + 1 + 64 = 129。

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

但我怀疑标准应该意味着63 + 1 + 63 = 127。

link: https://tools.ietf.org/html/rfc6838#section-4.2

#3


1  

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.

我们运行SaaS系统,允许用户上传文件。我们最初设计它来存储最多50个字符的MIME类型。在过去的几天里,我们已经看到了几次上传71字节类型的尝试。所以,我们改为250. 100似乎“好”,但它只比我们现在看到的最大值多一点。 500似乎很愚蠢,所以250是选定的。

#1


43  

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

我希望我不会误读,但看起来长度最多为127/127或255。

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

RFC 4288在4.2(第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.

我不清楚+后缀是否可以添加超过127,但似乎没有。

#2


5  

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

在RFC 6838(最新标准和废弃RFC4288)中,有以下声明。

"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."

“另请注意,虽然此语法允许最多127个字符的名称,但实现限制可能会使这些长名称出现问题。因此, 应限制为64个字符。”

64+1+64 = 129.

64 + 1 + 64 = 129。

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

但我怀疑标准应该意味着63 + 1 + 63 = 127。

link: https://tools.ietf.org/html/rfc6838#section-4.2

#3


1  

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.

我们运行SaaS系统,允许用户上传文件。我们最初设计它来存储最多50个字符的MIME类型。在过去的几天里,我们已经看到了几次上传71字节类型的尝试。所以,我们改为250. 100似乎“好”,但它只比我们现在看到的最大值多一点。 500似乎很愚蠢,所以250是选定的。