2016-08-25 1 views
0

Gibt es etwas anders in, wie Parse.Cloud.httpRequest Kompression behandelt?Parse.Cloud.httpRequest Antwort gzip Inflation/Dekomprimierung

Auf parse.com, ich habe nie eine XML-Datei mit dem Empfang, ein Problem hatte, aber unter Verwendung von Parse-Server auf einem anderen Host (back4app), meine httpResponse.text ist eine Last von:

�E��ڇ�*q�������y���v^�����

Parse.Cloud.job("fetchData", function(request, status) { 
Parse.Cloud.httpRequest({ 
     method: 'GET', 
     url: 'http://example.com/test.xml', 
     headers: { 
      'Accept': 'application/xml', 
      'Accept-Encoding': 'gzip, deflate' 
     }, 
     success: function (httpResponse) { 
      console.log("SUCCESS RECD FILE: " + httpResponse.text); 
     }, 
     error: function (httpResponse) { 
      console.log('An error has occured with the http request.: ' + httpResponse); 
     } 
    }); 
} 
+0

Parse ist kein Webserver, ich glaube, Sie es in Ihrem nginx oder Apache konfigurieren sollte ... –

+0

versuchen eine zip'd Antwort Handhabung .... http://stackoverflow.com/questions/12148948/ how-do-i-ungzip-dekomprimieren-a-nodejs-requests-modul-gzip-response-body –

Antwort

0

Vielen Dank für die große Unterstützung bei back4app, hier ist die Lösung

Grundsätzlich ist die Option gzip: true nirgendwo dokumentiert ist, ist aber notwendig.

Ich bin nicht sicher, ob die Header benötigt werden, aber ich habe sie trotzdem gelassen.

Parse.Cloud.httpRequest({ 

     url: 'http://example.com/feed.xml', 
     headers: { 
      'Content-Type': 'application/xml', 
      'Accept-Encoding': 'gzip, deflate' 
     }, 
     gzip:true, 
     success: function (httpResponse) { 
      ... 
     }, 
     error: function (httpResponse) { 
      ... 
     } 
}