【问题标题】:AngularJs $http.post() request is not working properlyAngularJs $http.post() 请求无法正常工作
【发布时间】:2017-04-30 22:35:25
【问题描述】:

AngularJs $http.post() 请求无法正常工作

我想将一项任务存储到我的数据库中。如果assignedMember 中的数据量大于175,它不会发送得到404 错误,但如果assignedMember 中的数据量小于175,它将发送成功并存储我的数据库。关于这个的任何想法。我不觉得我有什么问题。请帮帮我谢谢

这是我的 json 数据

$scope.task=

{
     "title": "My Title",
     "description": "My Description",
     "assignedMember": [
      {
       "userId": "51b701dae4b0dd92df2c32d1",
       "status": "ASSIGNED"
      },
      {
       "userId": "52de0811e4b04615ce7ed6bd",
       "status": "ASSIGNED"
      },
      {
       "userId": "559f8e97e4b0a5cdcd66bb76",
       "status": "ASSIGNED"
      },
    .
    .
    .
    .
    .
    .etc upto 500 data
     ]
}   

这是我的发帖请求 api

var responsePromise = $http.post("api/tasks",$scope.task);
responsePromise.success(function(data, status, headers, config) {
    alert("Data created successfully");
});
responsePromise.error(function(data, status, headers, config) {
alert("Error")
});

如果我发送此 json 时分配的成员大小超过 175 或浏览器中的内容长度大于 24580,我收到 404 错误

如果我发送此 json 时分配的成员大小小于 175 或浏览器中的内容长度小于 10080,它将成功

如果我收到 404 错误,我的浏览器控制台是这样的

Request header
-------------

Host: localhost

User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0

Accept: application/json, text/plain, /

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate

Content-Type: application/json;charset=utf-8

Referer: http://localhost/login.do

Content-Length: 24580

Response header
--------------


Connection: close

Content-Encoding: gzip

Content-Type: text/html

Date: Thu, 15 Dec 2016 14:21:56 GMT

Server: nginx/1.10.1

Transfer-Encoding: chunked

我的 nginx 服务器有什么限制吗?请帮帮我

发布请求没有限制吗?并且获取请求限制为 2048KB

实际上我是通过邮局发送的,所以我面临什么问题?

【问题讨论】:

    标签: angularjs json nginx


    【解决方案1】:

    Connection: close,我认为您的服务器没有接受大量数据。

    当客户端通过发送 413 响应并关闭连接来通知它将发送大于 client_max_body_size 的正文时,nginx“快速失败”。

    在发送整个请求正文之前,大多数客户端不会读取响应。因为 nginx 关闭了连接,所以客户端向关闭的 socket 发送数据,导致 TCP RST。

    如果您的 HTTP 客户端支持它,处理此问题的最佳方法是发送 Expect: 100-Continue 标头。 Nginx 从 1.2.7 开始正确支持此功能,如果 Content-Length 超过最大正文大小,将回复 413 Request Entity Too Large 响应而不是 100 Continue

    Referred from

    【讨论】:

    • 我听不懂姬,我该怎么办?请帮帮我?
    • 我添加了 ~client_body_in_file_only clean; client_body_buffer_size 32K; client_max_body_size 300M;发送文件; send_timeout 300s;~
    • 如何让我的服务器接受大量数据
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-03
    • 2014-04-21
    • 2018-02-18
    • 2018-07-13
    • 2015-09-16
    • 1970-01-01
    • 2014-10-20
    相关资源
    最近更新 更多