java - maxHttpHeaderSize 和 content-length 之间的区别

标签 java tomcat httprequest httpresponse

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. 

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

最佳答案

两者之间没有直接联系。

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

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

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

希望现在差异已经很明显了。 如果你想更好地了解HTTP协议(protocol),请从Hypertext_Transfer_Protocol开始

关于java - maxHttpHeaderSize 和 content-length 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290787/

相关文章:

java - 如何在 OpenGL ES 中移动带有纹理的形状?

java - 可重入锁定

java - 改造 - android.os.NetworkOnMainThreadException

Ajax 返回 404 即使页面存在

java - 调用 request.getReader() 后重置 HttpRequest

c++ - 如何使用 C++ 使用 recv() 函数接收大数据?

java - 无法执行目标 org.springframework.boot :spring-boot-maven-plugin:2. 5.5:run (default-cli)

spring-mvc - SpringMVC异常处理: How to display the parameter being passed in the error page?

tomcat - 访问 AWS EC2 实例上的 Tomcat 文件夹

node.js - 前端发送正常的http请求有哪些方式?