如果您要在数据库中存储一个用户代理,您将容纳多大的用户代理?
我发现这篇technet文章建议将UA保持在200以下。它看起来不像HTTP规范中定义的,至少我没有发现。我的UA已经有149个字符了,而且似乎每一个版本的。net都会增加它。
我知道我可以解析出字符串并分解它,但我宁愿不这样做。
编辑 基于此博客,IE9将更改为发送短UA字符串。这是一个很好的改变。
如果您要在数据库中存储一个用户代理,您将容纳多大的用户代理?
我发现这篇technet文章建议将UA保持在200以下。它看起来不像HTTP规范中定义的,至少我没有发现。我的UA已经有149个字符了,而且似乎每一个版本的。net都会增加它。
我知道我可以解析出字符串并分解它,但我宁愿不这样做。
编辑 基于此博客,IE9将更改为发送短UA字符串。这是一个很好的改变。
当前回答
这个大的怎么样?:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YPC 3.2.0; SearchSystem6829992239; SearchSystem9616306563; SearchSystem6017393645; SearchSystem5219240075; SearchSystem2768350104; SearchSystem6919669052; SearchSystem1986739074; SearchSystem1555480186; SearchSystem3376893470; SearchSystem9530642569; SearchSystem4877790286; SearchSystem8104932799; SearchSystem2313134663; SearchSystem1545325372; SearchSystem7742471461; SearchSystem9092363703; SearchSystem6992236221; SearchSystem3507700306; SearchSystem1129983453; SearchSystem1077927937; SearchSystem2297142691; SearchSystem7813572891; SearchSystem5668754497; SearchSystem6220295595; SearchSystem4157940963; SearchSystem7656671655; SearchSystem2865656762; SearchSystem6520604676; SearchSystem4960161466; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Hotbar 10.2.232.0; SearchSystem9616306563; SearchSystem6017393645; SearchSystem5219240075; SearchSystem2768350104; SearchSystem6919669052; SearchSystem1986739074; SearchSystem1555480186; SearchSystem3376893470; SearchSystem9530642569; SearchSystem4877790286; SearchSystem8104932799; SearchSystem2313134663; SearchSystem1545325372; SearchSystem7742471461; SearchSystem9092363703; SearchSystem6992236221; SearchSystem3507700306; SearchSystem1129983453; SearchSystem1077927937; SearchSystem2297142691; SearchSystem7813572891; SearchSystem5668754497; SearchSystem6220295595; SearchSystem4157940963; SearchSystem7656671655; SearchSystem2865656762; SearchSystem6520604676; SearchSystem4960161466; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
其他回答
这个大的怎么样?:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YPC 3.2.0; SearchSystem6829992239; SearchSystem9616306563; SearchSystem6017393645; SearchSystem5219240075; SearchSystem2768350104; SearchSystem6919669052; SearchSystem1986739074; SearchSystem1555480186; SearchSystem3376893470; SearchSystem9530642569; SearchSystem4877790286; SearchSystem8104932799; SearchSystem2313134663; SearchSystem1545325372; SearchSystem7742471461; SearchSystem9092363703; SearchSystem6992236221; SearchSystem3507700306; SearchSystem1129983453; SearchSystem1077927937; SearchSystem2297142691; SearchSystem7813572891; SearchSystem5668754497; SearchSystem6220295595; SearchSystem4157940963; SearchSystem7656671655; SearchSystem2865656762; SearchSystem6520604676; SearchSystem4960161466; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Hotbar 10.2.232.0; SearchSystem9616306563; SearchSystem6017393645; SearchSystem5219240075; SearchSystem2768350104; SearchSystem6919669052; SearchSystem1986739074; SearchSystem1555480186; SearchSystem3376893470; SearchSystem9530642569; SearchSystem4877790286; SearchSystem8104932799; SearchSystem2313134663; SearchSystem1545325372; SearchSystem7742471461; SearchSystem9092363703; SearchSystem6992236221; SearchSystem3507700306; SearchSystem1129983453; SearchSystem1077927937; SearchSystem2297142691; SearchSystem7813572891; SearchSystem5668754497; SearchSystem6220295595; SearchSystem4157940963; SearchSystem7656671655; SearchSystem2865656762; SearchSystem6520604676; SearchSystem4960161466; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
这个是257
Mozilla / 4.0 (compatible;MSIE 8.0;Windows NT 5.1;三叉戟/ 4.0;GTB6; .net CLR 1.1.4322;.net CLR 2.0.50727;.net CLR 3.0.04506.30; InfoPath.2;.net CLR 3.0.04506.648;OfficeLiveConnector.1.3; OfficeLivePatch.0.0;.net CLR 3.0.4506.2152;.net CLR 3.5.30729
这并不是一个用户代理可以达到多大的指示,因为有很多答案显示了他们遇到的边缘情况,但在http://www.useragentstring.com/pages/useragentstring.php?name=All上可以找到的最长的是250字节。
Mozilla / 4.0 (compatible;MSIE 8.0;Windows NT 6.1;三叉戟/ 4.0;SLCC2;.net CLR 2.0.50727;.net CLR 3.5.30729;.net CLR 3.0.30729;Media Center PC 6.0;媒体中心PC 5.0;SLCC1;OfficeLiveConnector.1.5;OfficeLivePatch.1.3;.NET4.0C;Lunascape 6.3。
我会给你一个标准答案:
取你能想到的最大的值,翻倍,这就是答案。
假设用户代理字符串的长度没有限制,并准备存储这样一个值。正如你所看到的,长度是不可预测的。
在Postgres中,有一种文本类型可以接受无限长度的字符串。使用它。
但最有可能的是,您必须在某个时刻开始截断。在一个相当有用的增量(200,1k, 4k)上称它为好,然后扔掉其余的。