HTTP GET请求的最大长度? [英] maximum length of HTTP GET request?

查看:148
本文介绍了HTTP GET请求的最大长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP GET请求的最大长度是多少?是否存在定义的响应错误,如果服务器收到超过此长度的GET请求,可以/应该返回?

What's the maximum length of an HTTP GET request? Is there a response error defined that the server can/should return if it receives a GET request exceeds this length?

更新:,如下所示标签,这是在Web服务API的上下文中,虽然看到浏览器限制也很有趣。

update: as indicated in the tags, this is in the context of a web service API, although it's interesting to see the browser limits as well.

推荐答案

限制取决于服务器和使用的客户端(如果适用,还取决于服务器或客户端使用的代理)。

The limit is dependent on both the server and the client used (and if applicable, also the proxy the server or the client is using).

大多数网络服务器的限制为8192字节(8KB),通常可在服务器配置的某处配置。至于客户端问题,HTTP 1.1规范甚至对此发出警告,这里是第3.2.1章

Most webservers have a limit of 8192 bytes (8KB), which is usually configureable somewhere in the server configuration. As to the client side matter, the HTTP 1.1 specification even warns about this, here's an extract of chapter 3.2.1:


注意:服务器应该谨慎依赖URI长度
高于255个字节,因为一些较旧的客户端或代理
实现可能无法正确支持这些长度。

限制在MSIE和Safari大约2KB,Opera大约4KB和Firefox大约8KB。因此,我们可以假设8KB是最大可能长度,并且2KB是服务器端依赖的更可承受的长度,并且假设整个URL将进入,255字节是最安全的长度。

The limit is in MSIE and Safari about 2KB, in Opera about 4KB and in Firefox about 8KB. We may thus assume that 8KB is the maximum possible length and that 2KB is a more affordable length to rely on at the server side and that 255 bytes is the safest length to assume that the entire URL will come in.

如果在浏览器或服务器中超出限制,大多数只会截断限制之外的字符而不会发出任何警告。 某些服务器可能会发送 HTTP 414错误。如果您需要发送大数据,那么最好使用POST而不是GET。它的限制更高,但更多地依赖于使用的服务器而不是客户端。通常,平均网络服务器允许高达2GB左右。这也可以在服务器设置中的某处进行配置。超过POST限制时,平均服务器将显示特定于服务器的错误/异常,通常为HTTP 500错误。

If the limit is exceeded in either the browser or the server, most will just truncate the characters outside the limit without any warning. Some servers however may send a HTTP 414 error. If you need to send large data, then better use POST instead of GET. Its limit is much higher, but more dependent on the server used than the client. Usually up to around 2GB is allowed by the average webserver. This is also configureable somewhere in the server settings. The average server will display a server-specific error/exception when the POST limit is exceeded, usually as HTTP 500 error.

这篇关于HTTP GET请求的最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆