0

在将我的应用程序从 Parse.com 迁移到 back4app 平台后,我们开始面临云代码功能的问题。

我有一个调用以下网址的云代码功能:http: //www.pro.co.il/homeler/test.asp? c=6&a=51

错误是: { [Error: Parse Error] bytesParsed: 373, code: 'HPE_UNEXPECTED_CONTENT_LENGTH' }

云码功能:

    Parse.Cloud.define("getFromPro", function (request, response) {
    return Parse.Cloud.httpRequest({
    url: 'http://www.pro.co.il/homeler/test.asp?c=' + request.params.classification + '&a=' + request.params.area,
    method: 'GET',
    headers: {
    'Content-Type': 'application/json;charset=utf-8'
    }
    }).then(function (httpResponse) {
        response.success(httpResponse);
    }, function (httpResponse) {
        response.error("not ok");
    });
});

知道问题是否出在 back4app 服务器上,或者我可以在我的云代码功能中修复它吗?

4

1 回答 1

1

问题是您从 pro.co.il 获得的响应有两个内容长度标头:

curl -v http://www.pro.co.il/homeler/test.asp\?c\=6\&a\=51  
* Trying 195.190.23.112...
* Connected to www.pro.co.il (195.190.23.112) port 80 (#0)
> GET /homeler/test.asp?c=6&a=51 HTTP/1.1
> Host: www.pro.co.il
> User-Agent: curl/7.49.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Length: 1583
< Content-Type: text/html; Charset=UTF-8
< Expires: Sun, 31 Dec 1989 22:00:00 GMT
< Set-Cookie: ASPSESSIONIDCSCTSQSS=OBFNBKCBBPEDLKCIJNNLBJCD; path=/
< X-Powered-By: ASP.NET
< Accept-Ranges: bytes
< Date: Sat, 22 Oct 2016 15:08:28 GMT
< X-Varnish: 1532078109
< Age: 0
< Via: 1.1 varnish
< Connection: keep-alive
< Content-Length: 1583

当您从 parse.com 移动到 parse-server 时,用于制作 Parse.Cloud.request 的库更改为https://github.com/request/request,它使用节点 http 库,出于安全原因对标头严格(尽管如果重复的内容长度匹配,就像在这种情况下,不出错是合理的,因为它不会造成安全风险)。

您可以在此处阅读有关此问题的信息:https ://github.com/nodejs/node/issues/6517

我查看了请求选项,看看你是否可以关闭它,但看起来你不能。

您是否有可能让 pro.co.il 修复他们破坏的响应?

于 2016-10-22T15:14:41.823 回答