2016-12-15 101 views
2

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") 
}); 

如果分配的成员规模超过175或在浏览器内容长度大于24580当我发送此json我得到404错误

如果指定的成员大小小于175或浏览器中的内容长度小于10080当我发送此json它会成功

如果我收到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服务器中的任何限制?请帮我

发布请求没有限制rit?并获得请求被限制为2048KB

其实我通过邮寄发送,所以我面临什么问题?

回答

0

Connection: close,我认为你的服务器不接受大量的数据。

nginx的“失败快”,当客户端通知它它会通过发送413响应,并关闭连接发送的身体比client_max_body_size大。

大多数客户端在发送整个请求主体之前不会读取响应。由于nginx关闭连接,客户端将数据发送到关闭的套接字,导致TCP RST。

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

Referred from

+0

我不能理解姬,我会做什么?请帮助我? –

+0

我添加了〜client_body_in_file_only clean; client_body_buffer_size 32K; client_max_body_size 300M; sendfile on; send_timeout 300s;〜 –

+0

但它不起作用 –