From f670678cf0886ba01429a368a1a166ddc5256258 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Mon, 29 May 2023 23:24:06 +0200 Subject: [PATCH] WIP accept header --- .../cornerstone/src/initWADOImageLoader.js | 14 ---- .../default/src/DicomWebDataSource/index.js | 69 ++----------------- 2 files changed, 6 insertions(+), 77 deletions(-) diff --git a/extensions/cornerstone/src/initWADOImageLoader.js b/extensions/cornerstone/src/initWADOImageLoader.js index 5727b16d3..c21326b5f 100644 --- a/extensions/cornerstone/src/initWADOImageLoader.js +++ b/extensions/cornerstone/src/initWADOImageLoader.js @@ -54,20 +54,6 @@ export default function initWADOImageLoader( // we should set this flag to false. convertFloatPixelDataToInt: false, }, - /* - TODO (Salim) : Seems to be implemented in createDicomWebApi, check if safe to remove - beforeSend: function (xhr) { - const headers = userAuthenticationService.getAuthorizationHeader(); - - const xhrRequestHeaders = {} - - if (headers) { - Object.assign(xhrRequestHeaders, headers); - } - - return xhrRequestHeaders; - }, - */ errorInterceptor: error => { errorHandler.getHTTPErrorHandler(error); }, diff --git a/extensions/default/src/DicomWebDataSource/index.js b/extensions/default/src/DicomWebDataSource/index.js index ca3482e7d..5c8a18880 100644 --- a/extensions/default/src/DicomWebDataSource/index.js +++ b/extensions/default/src/DicomWebDataSource/index.js @@ -60,73 +60,16 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) { supportsReject, staticWado, singlepart, - requestTransferSyntaxUID, - omitQuotationForMultipartRequest + omitQuotationForMultipartRequest, + acceptHeader } = dicomWebConfig; const dicomWebConfigCopy = JSON.parse(JSON.stringify(dicomWebConfig)); - const acceptHeader = ['multipart/related'] - - if (requestTransferSyntaxUID) { - - // Request: - // JPEG-LS Lossless (1.2.840.10008.1.2.4.80) if available, otherwise accept - // whatever transfer-syntax the origin server provides. - // For now we use image/jls and image/x-jls because some servers still use the old type - // http://dicom.nema.org/medical/dicom/current/output/html/part18.html - /* - taken from - https://hg.orthanc-server.com/orthanc-dicomweb/file/tip/Plugin/WadoRsRetrieveFrames.cpp - */ - - /* - Hard coding this prevents adding custom types here such as the single part, or adding priority. - Suggest dropping this table. - */ - - const typeForTS = { - "*": "application/octet-stream", - "1.2.840.10008.1.2.1": "application/octet-stream", - "1.2.840.10008.1.2": "application/octet-stream", - "1.2.840.10008.1.2.2": "application/octet-stream", - "1.2.840.10008.1.2.4.70": "image/jpeg", - "1.2.840.10008.1.2.4.50": "image/jpeg", - "1.2.840.10008.1.2.4.51": "image/dicom+jpeg", - "1.2.840.10008.1.2.4.57": "image/jpeg", - "1.2.840.10008.1.2.5": "image/dicom-rle", - "1.2.840.10008.1.2.4.80": "image/jls", - "1.2.840.10008.1.2.4.81": "image/jls", - "1.2.840.10008.1.2.4.90": "image/jp2", - "1.2.840.10008.1.2.4.91": "image/jp2", - "1.2.840.10008.1.2.4.92": "image/jpx", - "1.2.840.10008.1.2.4.93": "image/jpx", - } - - - /* - This should be the default TSUID, - but the actual request should be able to over-ride the requested TSUID. - Why not just allow configuring the default accept header - INCLUDING making it empty? - If it were set as an array of strings, then an empty array wouldn't set it, and would allow the default response to be sent. - Also, it is permissable to request single part types directly, - and it would be nice to allow that to be configured using the same mechanism - - for example: dataSource....defaultImageAccept: [] would not pass any accept header - (this is required to work on all DICOMweb servers) - dataSource...defaultImageAccept: ['multipart/related; type="image/jphc"', 'multipart/related; type="image/jpeg"] - would allow for either HTJ2K or JPEG responses - something that can be very important when fetching existing lossy encoded images. - Then, dataSource...defaultImageAccept: ['image/jpeg', 'image/jp2'] would return JPEG or JPEG2000 responses. - */ - //Check TS is valid - if (!typeForTS[requestTransferSyntaxUID]) { - console.warn(requestTransferSyntaxUID + 'is unexpected') - } else { - //Fetch type header according to requesting TS - let type = typeForTS[requestTransferSyntaxUID] - acceptHeader.push('type=' + type) - acceptHeader.push('transfer-syntax=' + requestTransferSyntaxUID) - } - + //If accept header is not specified, set as multipart + let formattedAcceptHeader = acceptHeader ?? [] + if (acceptHeader.length === 0) { + formattedAcceptHeader = ['multipart/related'] } if (!omitQuotationForMultipartRequest) {