Revert "Merge branch 'master' of github.com:OHIF/Viewers"
This reverts commit137007c220, reversing changes made toaf639b4de2.
This commit is contained in:
parent
137007c220
commit
2cf666f7a5
@ -1,57 +1,30 @@
|
|||||||
var http = Npm.require('http'), url = Npm.require('url');
|
DICOMWeb.getJSON = function(url, options) {
|
||||||
|
var getOptions = {
|
||||||
function makeRequest(geturl, options, callback) {
|
|
||||||
var parsed = url.parse(geturl), jsonHeaders = ['application/json', 'application/dicom+json'];
|
|
||||||
|
|
||||||
var requestOpt = {
|
|
||||||
hostname: parsed.hostname,
|
|
||||||
port: parsed.port,
|
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json'
|
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 = '';
|
if (options.auth) {
|
||||||
resp.setEncoding('utf8');
|
getOptions.auth = options.auth;
|
||||||
resp.on('data', function(chunk){
|
}
|
||||||
output += chunk;
|
|
||||||
});
|
|
||||||
resp.on('end', function(){
|
|
||||||
callback(null, {data: JSON.parse(output)});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.end();
|
|
||||||
}
|
|
||||||
var makeRequestSync = Meteor.wrapAsync(makeRequest);
|
|
||||||
|
|
||||||
DICOMWeb.getJSON = function(geturl, options) {
|
|
||||||
if (options.logRequests) {
|
if (options.logRequests) {
|
||||||
console.log(geturl);
|
console.log(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.logTiming) {
|
if (options.logTiming) {
|
||||||
console.time(geturl);
|
console.time(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = makeRequestSync(geturl, options);
|
var result = HTTP.get(url, getOptions);
|
||||||
|
|
||||||
if (options.logTiming) {
|
if (options.logTiming) {
|
||||||
console.timeEnd(geturl);
|
console.timeEnd(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.logResponses) {
|
if (options.logResponses) {
|
||||||
console.log(result);
|
console.log(result.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user