The Below code works effectively in getting to the file but seems to only retreive maybe 1/4 of it, I have noticed that the data event only fires once and then immediately the end event fires so it seems it is only getting the first chunk and returning it and not continueing to get the rest, this confuses me, am I doing something wrong? also below are the headers being sent.
var urlObj = require('url');
var http = require('http');
var https = require('https');
var fs = require('fs');
//var Buffer = require('buffer');
var contents = "";
function requestData(url)
{
var options =
{
host: url,
port: 8443,
path: params,
method: 'GET',
headers: {'Content-Type' : 'application/json','Content-Length':Buffer.byteLength(contents, 'utf8')},
secureProtocol: 'SSLv3_method',
strictSSL: false,
rejectUnauthorized: false
};
var reqGet = https.get(options,function(res)
{
console.log("headers: ", res.headers);
res.setEncoding = 'utf8';
res.on("data", function(c)
{
console.log(c.toString());
contents += c.toString();
});
res.on("end", function ()
{
console.log(contents);
writeContents(contents);
});
res.on('error', function(err)
{
console.log('error: '+err);
});
});
}
requestData(url);
Headers:
{ server: 'Apache-Coyote/1.1',
'JSESSIONID=sessionId; Path=/; Secure; HttpOnly' ],
'x-ausername': 'anonymous',
'cache-control': 'no-cache, no-store, no-transform',
'content-type': 'application/json;charset=UTF-8',
'transfer-encoding': 'chunked',
date: 'Mon, 28 Jul 2014 16:08:58 GMT' }
EDIT: Nevermind, looks like its a header issue and has to do with my login authorization, anonymous can only seem to get 3 listings, the things I'm looking for now are how to pass my logged in state :( X-AUSERNAME: name and X-Seraph-LoginReason: OK. would anyone know how to do this?
needed to add headers:{'Authorization':[base64 encoded username+pass]} for correct login authorization. In case anyone else runs into this problem.