从http 414(Request-URI Too Long)说起------RFC并未限制URL的长度

       在一些服务器中, 如果url过长, 会产生414错误(依赖于具体实现)。 也有很多人认为,get参数有长度限制, post没有限制。对吗? 显然不对。

       实际上, RFC并未规定url长度, 只是浏览器和服务器实现的时候, 对url的长度加了限制而已。

       来看看:

      The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).
      Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

       

        对于url:

        在浏览器端, 以大众常用的IE为例, 限制大约是2K字节, 以程序员常用的chrome为例, 限制是8K字节。

        在服务端, 以最常见的apache服务器为例, 限制是8K字节, 其他服务器则可能各部相同。

扫描二维码关注公众号,回复: 2732604 查看本文章

        再强调一次, 即使在具体实现中有限制, 也是限制url, 而非整个请求体。 所以, 以经典的chrome + apache为例,  如果要传输1M的数据,当然不能放在http的url参数中, 所以一般不选择get, 而选择post.

        不多说。

        

       

猜你喜欢

转载自blog.csdn.net/stpeace/article/details/81262586