【问题标题】:difference between maxHttpHeaderSize and content-lengthmaxHttpHeaderSize 和 content-length 的区别
【发布时间】:2015-07-08 11:03:41
【问题描述】:

Apache tomcat server.xml 中的 maxHttpHeaderSize 和 HttpServletRequest/HttpServletResponse 中的 content-length 有什么区别。

    maxHttpHeaderSize  -  The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 4096 (4 KB).

content-Length  -The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET. 

这两个参数之间有什么关系吗?

【问题讨论】:

  • 消息头字段长度vs消息体内容长度(rfc2616),一目了然,这两个参数之间没有关系。
  • 一个是最大标题大小:另一个是实际内容大小。没有任何联系。

标签: java tomcat httprequest httpresponse


【解决方案1】:

两者之间没有直接联系。

内容长度是一个HTTP header field,它以八位字节(8 位字节)指定请求正文的长度。它是所有 HTTP 请求的通用字段,与 Apache Tomcat 没有特定连接。

maxHttpHeaderSize 字段是 Apache Tomcat 配置文件中的一个配置字段——它限制了服务器发送/接收的任何 HTTP 标头的大小(我认为是出于安全/或网络优化的原因)。

HttpServletRequest/HttpServletResponse 是用于为 HTTP servlet 提供请求信息的接口: 例如,您可以使用它来获取发送/接收的 HTTP 请求的 CONTENT_LENGTH 信息。

希望现在区别很明显。 如果你想更好地理解HTTP协议,请从Hypertext_Transfer_Protocol开始

【讨论】:

    猜你喜欢
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 2013-04-22
    • 2014-01-08
    • 1970-01-01
    相关资源
    最近更新 更多