Revert "Merge branch 'master' of github.com:OHIF/Viewers"

This reverts commit 137007c220, reversing
changes made to af639b4de2.
This commit is contained in:
weiwei 2016-10-24 22:17:22 +08:00
parent 137007c220
commit 2cf666f7a5

View File

@ -1,57 +1,30 @@
var http = Npm.require('http'), url = Npm.require('url');
function makeRequest(geturl, options, callback) {
var parsed = url.parse(geturl), jsonHeaders = ['application/json', 'application/dicom+json'];
var requestOpt = {
hostname: parsed.hostname,
port: parsed.port,
DICOMWeb.getJSON = function(url, options) {
var getOptions = {
headers: {
Accept: 'application/json'
},
path: parsed.path,
method: 'GET'
};
if (options.auth) {
requestOpt.auth = options.auth;
}
var req = http.request(requestOpt, function(resp) {
if (jsonHeaders.indexOf(resp.headers['content-type']) == -1) {
callback('We only support json', null);
return;
}
};
var output = '';
resp.setEncoding('utf8');
resp.on('data', function(chunk){
output += chunk;
});
resp.on('end', function(){
callback(null, {data: JSON.parse(output)});
});
});
req.end();
}
var makeRequestSync = Meteor.wrapAsync(makeRequest);
if (options.auth) {
getOptions.auth = options.auth;
}
DICOMWeb.getJSON = function(geturl, options) {
if (options.logRequests) {
console.log(geturl);
console.log(url);
}
if (options.logTiming) {
console.time(geturl);
console.time(url);
}
var result = makeRequestSync(geturl, options);
var result = HTTP.get(url, getOptions);
if (options.logTiming) {
console.timeEnd(geturl);
console.timeEnd(url);
}
if (options.logResponses) {
console.log(result);
console.log(result.data);
}
return result;