var http = require('http')
function getSPARQLResults(query_string, callback) {
sparqlQ = getSPARQLPrefix() + query_string;
var options = {
host: 'localhost',
port: 8080,
path: '/openrdf-sesame/repositories/myRepo?query=' +encodeURIComponent(sparqlQ) + '&content-type=application/sparql-results+json',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/sparql-results+json',
},
};
//console.log ( encodeURIComponent(query_string) );
console.log ( query_string );
var req = http.get(options, function(res) {
console.log("Got response: " + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
var data = "";
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function () {
console.log (data);
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
req.end();
}
RESPONSE (node.js サーバーが Amazon EC2 Linux インスタンスで実行されている場合)
Got response: 400
HEADERS: {"date":"Wed, 24 Apr 2013 04:12:12 GMT","content-language":"en-US","content-type":"text/plain; charset=utf-8","content-length":"86","server":"Jetty(6.1.26)"}
undefined:1
MALFORMED QUERY: Lexical error at line 1, column 7. Encountered: "%" (37), af
^
RESPONSE (node.js サーバーが Ubuntu ラップトップで実行されている場合)
Got response: 200
HEADERS: {"date":"Wed, 24 Apr 2013 04:20:37 GMT","vary":"Accept","content-language":"en-US","content-type":"application/sparql-results+json; charset=UTF-8","content-disposition":"attachment; filename=query-result.srj","transfer-encoding":"chunked","server":"Jetty(6.1.26)"}
Content-Type は、2 つのヘッダー間で異なります。何が足りない/うまくいかないのですか??