Fixing Server Information Modal issues
This commit is contained in:
parent
150817d711
commit
4315f47b61
@ -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) {
|
||||
|
||||
@ -1 +1,2 @@
|
||||
import './collections';
|
||||
import './components';
|
||||
|
||||
@ -8,6 +8,7 @@ Package.onUse(function(api) {
|
||||
api.versionsFrom('1.4');
|
||||
|
||||
api.use('ecmascript');
|
||||
api.use('templating');
|
||||
api.use('jquery');
|
||||
api.use('stylus');
|
||||
api.use('aldeed:simple-schema');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user