Fixing Server Information Modal issues

This commit is contained in:
Bruno Alves de Faria committed 2017-07-12 09:18:17 -03:00
1 parent 150817d711
commit 4315f47b61
3 files changed
+12 -6

No files matched your search

@@ -1,3 +1,5 @@
import { Meteor } from 'meteor/meteor';
const http = Npm.require('http');
const https = Npm.require('https');
const url = Npm.require('url');
@@ -20,7 +22,7 @@ function makeRequest(geturl, options, callback) {
requester = https.request;
const allowUnauthorizedAgent = new https.Agent({ rejectUnauthorized: false });
requestOpt.agent = allowUnauthorizedAgent
requestOpt.agent = allowUnauthorizedAgent;
} else {
requester = http.request;
}
@@ -41,8 +43,9 @@ function makeRequest(geturl, options, callback) {
}
const req = requester(requestOpt, function(resp) {
// TODO: handle errors with 400+ code
const contentType = (resp.headers['content-type'] || '').split(';')[0];
if (jsonHeaders.indexOf(contentType) == -1) {
if (jsonHeaders.indexOf(contentType) === -1) {
const errorMessage = `We only support json but "${contentType}" was sent by the server`;
callback(new Error(errorMessage), null);
return;
@@ -50,15 +53,16 @@ function makeRequest(geturl, options, callback) {
let output = '';
resp.setEncoding('utf8');
resp.on('data', function(chunk){
output += chunk;
resp.on('data', function(chunk) {
output += chunk;
});
resp.on('end', function(){
callback(null, {data: JSON.parse(output)});
resp.on('end', function() {
callback(null, { data: JSON.parse(output) });
});
});
req.end();
}
const makeRequestSync = Meteor.wrapAsync(makeRequest);
DICOMWeb.getJSON = function(geturl, options) {