Request options are now properly passed into WADO Proxy (LT-165)
This commit is contained in:
parent
c05e36eca8
commit
ed8bb26fa4
@ -11,7 +11,6 @@ Package.onUse(function(api) {
|
|||||||
api.use('standard-app-packages');
|
api.use('standard-app-packages');
|
||||||
api.use('clinical:router');
|
api.use('clinical:router');
|
||||||
|
|
||||||
|
|
||||||
api.addFiles('server/namespace.js');
|
api.addFiles('server/namespace.js');
|
||||||
|
|
||||||
// Server-only
|
// Server-only
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Settings = Object.assign((Meteor.settings && Meteor.settings.proxy) ? Meteor.settings.proxy : {}, {
|
Settings = Object.assign((Meteor.settings && Meteor.settings.proxy) ? Meteor.settings.proxy : {}, {
|
||||||
uri : "/__wado_proxy",
|
uri : "/__wado_proxy",
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
WADOProxy = {};
|
WADOProxy = {};
|
||||||
|
|
||||||
WADOProxy.convertURL = function(wadoURL) {
|
WADOProxy.convertURL = (wadoURL, requestOptions) => {
|
||||||
if (!Settings.enabled) {
|
if (!Settings.enabled) {
|
||||||
return wadoURL;
|
return wadoURL;
|
||||||
}
|
}
|
||||||
return Settings.uri + '?' + querystring.stringify({url: wadoURL});
|
if (!wadoURL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Settings.uri + '?' + querystring.stringify({url: wadoURL, options: requestOptions ? JSON.stringify(requestOptions) : null});
|
||||||
}
|
}
|
||||||
@ -1,33 +1,64 @@
|
|||||||
Router.route(Settings.uri, function () {
|
// Setup a Route using Iron Router to avoid Cross-origin resource sharing
|
||||||
let response = this.response;
|
// (CORS) errors. We only handle this route on the Server.
|
||||||
if (!this.params.query.url) {
|
Router.route(Settings.uri, function() {
|
||||||
|
const request = this.request;
|
||||||
|
const response = this.response;
|
||||||
|
const params = this.params;
|
||||||
|
const requestOptions = params.query.options ? JSON.parse(params.query.options) : {};
|
||||||
|
|
||||||
|
// If no Web Access to DICOM Objects (WADO) Service URL is provided
|
||||||
|
// return an error for the request.
|
||||||
|
if (!params.query.url) {
|
||||||
response.writeHead(500);
|
response.writeHead(500);
|
||||||
response.end('No wado url provided');
|
response.end('Error: No WADO URL was provided.\n');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let proxyRequest,
|
// Use Node's URL parse to decode the query URL
|
||||||
wadoUrl = url.parse(this.params.query.url, false);
|
const wadoUrl = url.parse(params.query.url);
|
||||||
|
|
||||||
var options = {
|
// Create an object to hold the information required
|
||||||
headers: {}
|
// for the request to the PACS.
|
||||||
|
let options = {
|
||||||
|
headers: {},
|
||||||
|
method: request.method,
|
||||||
|
hostname: wadoUrl.hostname,
|
||||||
|
port: wadoUrl.port, //maybe null
|
||||||
|
path: wadoUrl.path,
|
||||||
};
|
};
|
||||||
//options.headers = this.request.headers;
|
|
||||||
if (this.request.headers['referer']) {
|
if (request.headers['referer']) {
|
||||||
options.headers.referer = this.request.headers['referer'];
|
options.headers.referer = request.headers['referer'];
|
||||||
}
|
}
|
||||||
if (this.request.headers['user-agent']) {
|
if (request.headers['user-agent']) {
|
||||||
options.headers['user-agent'] = this.request.headers['user-agent'];
|
options.headers['user-agent'] = request.headers['user-agent'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the authorization user:password string for the PACS,
|
||||||
|
// if one is required, and include it in the request to the PACS.
|
||||||
|
//const wadoAuth = 'orthanc:orthanc';
|
||||||
|
if (requestOptions.auth) {
|
||||||
|
options.auth = requestOptions.auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.method = this.request.method;
|
// Use Node's HTTP API to send a request to the PACS
|
||||||
options.host = wadoUrl.hostname;
|
const proxyRequest = http.request(options, (proxyResponse) => {
|
||||||
options.port = wadoUrl.port ? wadoUrl.port : 80;
|
// When we receive data from the PACS, stream it as the
|
||||||
options.path = wadoUrl.path;
|
// response to the original request.
|
||||||
|
// console.log(`Got response: ${proxyResponse.statusCode}`);
|
||||||
proxyRequest = http.request(options, function (proxyResponse) {
|
response.writeHead(proxyResponse.statusCode, proxyResponse.headers);
|
||||||
proxyResponse.pipe(response, {end: true});
|
return proxyResponse.pipe(response, {end: true});
|
||||||
});
|
});
|
||||||
//proxyRequest.end();
|
|
||||||
this.request.pipe(proxyRequest, {end: true});
|
// If our request to the PACS fails, log the error message
|
||||||
}, {where: 'server'});
|
proxyRequest.on('error', (error) => {
|
||||||
|
response.writeHead(500);
|
||||||
|
response.end(`Error: Problem with request to PACS: ${error.message}\n`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Stream the original request information into the request
|
||||||
|
// to the PACS
|
||||||
|
request.pipe(proxyRequest);
|
||||||
|
}, {
|
||||||
|
where: 'server'
|
||||||
|
});
|
||||||
@ -111,7 +111,7 @@ function resultDataToStudyMetadata(studyInstanceUid, resultData) {
|
|||||||
|
|
||||||
// Retrieve the actual data over WADO-URI
|
// Retrieve the actual data over WADO-URI
|
||||||
var server = Meteor.settings.servers.dicomWeb[0];
|
var server = Meteor.settings.servers.dicomWeb[0];
|
||||||
instanceSummary.wadouri = WADOProxy.convertURL(server.wadoUriRoot + '?requestType=WADO&studyUID=' + studyInstanceUid + '&seriesUID=' + seriesInstanceUid + '&objectUID=' + sopInstanceUid + "&contentType=application%2Fdicom");
|
instanceSummary.wadouri = WADOProxy.convertURL(server.wadoUriRoot + '?requestType=WADO&studyUID=' + studyInstanceUid + '&seriesUID=' + seriesInstanceUid + '&objectUID=' + sopInstanceUid + "&contentType=application%2Fdicom", server.requestOptions);
|
||||||
|
|
||||||
series.instances.push(instanceSummary);
|
series.instances.push(instanceSummary);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -116,7 +116,7 @@ function resultDataToStudyMetadata(server, studyInstanceUid, resultData) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (server.imageRendering === 'wadouri') {
|
if (server.imageRendering === 'wadouri') {
|
||||||
instanceSummary.wadouri = WADOProxy.convertURL(server.wadoUriRoot + '?requestType=WADO&studyUID=' + studyInstanceUid + '&seriesUID=' + seriesInstanceUid + '&objectUID=' + sopInstanceUid + '&contentType=application%2Fdicom');
|
instanceSummary.wadouri = WADOProxy.convertURL(server.wadoUriRoot + '?requestType=WADO&studyUID=' + studyInstanceUid + '&seriesUID=' + seriesInstanceUid + '&objectUID=' + sopInstanceUid + '&contentType=application%2Fdicom', server.requestOptions);
|
||||||
} else {
|
} else {
|
||||||
instanceSummary.wadorsuri = server.wadoRoot + '/studies/' + studyInstanceUid + '/series/' + seriesInstanceUid + '/instances/' + sopInstanceUid + '/frames/1';
|
instanceSummary.wadorsuri = server.wadoRoot + '/studies/' + studyInstanceUid + '/series/' + seriesInstanceUid + '/instances/' + sopInstanceUid + '/frames/1';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"name": "DCM4CHEE",
|
"name": "DCM4CHEE",
|
||||||
"wadoUriRootNOTE": "either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently",
|
"wadoUriRootNOTE": "either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently",
|
||||||
"wadoUriRoot": "http://localhost:8043/dcm4chee-arc/aets/DCM4CHEE/wado",
|
"wadoUriRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/wado",
|
||||||
"qidoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
"qidoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||||
"wadoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
"wadoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||||
"qidoSupportsIncludeField": false,
|
"qidoSupportsIncludeField": false,
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Orthanc",
|
"name": "Orthanc",
|
||||||
"wadoUriRootNOTE": "either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently",
|
"wadoUriRootNOTE": "either this uri is not correct for wado-uri or wado-uri is not configured on orthanc currently",
|
||||||
"wadoUriRoot": "http://localhost:8043/wado",
|
"wadoUriRoot": "http://localhost:8042/wado",
|
||||||
"qidoRoot": "http://localhost:8042/dicom-web",
|
"qidoRoot": "http://localhost:8042/dicom-web",
|
||||||
"wadoRoot": "http://localhost:8042/dicom-web",
|
"wadoRoot": "http://localhost:8042/dicom-web",
|
||||||
"qidoSupportsIncludeField": false,
|
"qidoSupportsIncludeField": false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user