【问题标题】:How can I increase the size limit of a POST request?如何增加 POST 请求的大小限制?
【发布时间】:2015-03-18 01:13:27
【问题描述】:

我正在开发一个 Android 应用程序,并且我正在使用 kevinsawicki/http-request 库发送一个复杂的 json 数据(带有 base64 编码的图像)。

我正在做这样的事情:

HttpRequest request =  HttpRequest.post(url)
    .header("Content-Type", "application/json")
    .send(data);

request.created() 返回 falserequest.code() 返回 http 代码 413

这段代码是……

413 请求实体太大。服务器不会接受请求,因为请求实体太大

所以,我需要增加大小限制,以便发送如此大量的数据。我怎样才能做到这一点?

【问题讨论】:

  • 这是在服务器上设置的。您需要使用网络服务器的设置,这与 SO 无关。尝试超级用户(这一次它实际上是正确的地方!)

标签: java android post http-headers


【解决方案1】:

如果您的后端服务器是 tomcat 和 jboss,它们的默认最大帖子大小为 2M。

请参考以下链接:

http://tomcat.apache.org/tomcat-7.0-doc/config/ajp.html https://docs.jboss.org/jbossweb/2.1.x/config/http.html

maxPostSize 
The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

【讨论】:

    猜你喜欢
    • 2018-08-16
    • 2023-03-16
    • 1970-01-01
    • 2012-07-26
    • 2022-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    相关资源
    最近更新 更多