[Ready] fix 5288 removal of accept header options in retrieve metadata (#5293)
* chore: Minor adjustment to generateAcceptHeader function signature to reflect expected return type. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * fix: Added switch to skip the Accept header generation when requesting metadata. WADO metadata request is more likely to return JSON and some VNAs do not like the extra options in the Accept header. Also, passing an empty array is not sufficient because somewhere we still include a comma that breaks the Accept header. It's better to omit it for the metadata request only. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Added new HeadersInterface interface type docstrings. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Refactored getAuthorizationHeader() function signature so it is typed checked. Of course, I upgraded the module to a TypeScript module. Moved the request header interfaces into its own TypeScript module (RequestHeaders.ts) in the core types. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Refactored the user logic to include a TypeScript interface. As a result, upgraded the source file to TypeScript. Removed the User interface from RequestHeaders module and moved them to the user module. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Updated function signatures, user import, and confirmed unit tests are passing. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Minor stylistic adjustment to getAuthorizationHeader.test.ts Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore: Added missing comments. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * chore adjusted generateWadoHeader parameter's name and added comment about the expected default header. Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> * Just tweaking the interface a bit to be more consistent. * fix authorization header signature change --------- Signed-off-by: Luis M. Santos <luis.santos2@nih.gov> Co-authored-by: Bill Wallace <wayfarer3130@gmail.com> Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
9 files changed
+135
-47
No files matched your search
@@ -16,6 +16,7 @@ import { retrieveStudyMetadata, deleteStudyMetadataPromise } from './retrieveStu
|
||||
import StaticWadoClient from './utils/StaticWadoClient';
|
||||
import getDirectURL from '../utils/getDirectURL';
|
||||
import { fixBulkDataURI } from './utils/fixBulkDataURI';
|
||||
import {HeadersInterface} from '@ohif/core/src/types/RequestHeaders';
|
||||
|
||||
const { DicomMetaDictionary, DicomDict } = dcmjs.data;
|
||||
|
||||
@@ -97,6 +98,20 @@ export type BulkDataURIConfig = {
|
||||
relativeResolution?: 'studies' | 'series';
|
||||
};
|
||||
|
||||
/**
|
||||
* The header options are the options passed into the generateWadoHeader
|
||||
* command. This takes an extensible set of attributes to allow future enhancements.
|
||||
*/
|
||||
export interface HeaderOptions {
|
||||
includeTransferSyntax?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Metadata and some other requests don't permit the transfer syntax to be included,
|
||||
* so pass in the excludeTransferSyntax parameter.
|
||||
*/
|
||||
export const excludeTransferSyntax: HeaderOptions = { includeTransferSyntax: false };
|
||||
|
||||
/**
|
||||
* Creates a DICOM Web API based on the provided configuration.
|
||||
*
|
||||
@@ -128,7 +143,7 @@ function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) {
|
||||
dicomWebConfigCopy = JSON.parse(JSON.stringify(dicomWebConfig));
|
||||
|
||||
getAuthorizationHeader = () => {
|
||||
const xhrRequestHeaders = {};
|
||||
const xhrRequestHeaders: HeadersInterface = {};
|
||||
const authHeaders = userAuthenticationService.getAuthorizationHeader();
|
||||
if (authHeaders && authHeaders.Authorization) {
|
||||
xhrRequestHeaders.Authorization = authHeaders.Authorization;
|
||||
@@ -136,19 +151,33 @@ function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) {
|
||||
return xhrRequestHeaders;
|
||||
};
|
||||
|
||||
generateWadoHeader = () => {
|
||||
/**
|
||||
* Generates the wado header for requesting resources from DICOMweb.
|
||||
* These are classified into those that are dependent on the transfer syntax
|
||||
* and those that aren't, as defined by the include transfer syntax attribute.
|
||||
*/
|
||||
generateWadoHeader = (options: HeaderOptions): HeadersInterface => {
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
//Generate accept header depending on config params
|
||||
const formattedAcceptHeader = utils.generateAcceptHeader(
|
||||
dicomWebConfig.acceptHeader,
|
||||
dicomWebConfig.requestTransferSyntaxUID,
|
||||
dicomWebConfig.omitQuotationForMultipartRequest
|
||||
);
|
||||
|
||||
return {
|
||||
...authorizationHeader,
|
||||
Accept: formattedAcceptHeader,
|
||||
};
|
||||
if (options?.includeTransferSyntax!==false) {
|
||||
//Generate accept header depending on config params
|
||||
const formattedAcceptHeader = utils.generateAcceptHeader(
|
||||
dicomWebConfig.acceptHeader,
|
||||
dicomWebConfig.requestTransferSyntaxUID,
|
||||
dicomWebConfig.omitQuotationForMultipartRequest
|
||||
);
|
||||
return {
|
||||
...authorizationHeader,
|
||||
Accept: formattedAcceptHeader,
|
||||
};
|
||||
} else {
|
||||
// The base header will be included in the request. We simply skip customization options around
|
||||
// transfer syntaxes and whether the request is multipart. In other words, a request in
|
||||
// which the server expects Accept: application/dicom+json will still include that in the
|
||||
// header.
|
||||
return {
|
||||
...authorizationHeader
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
qidoConfig = {
|
||||
@@ -410,7 +439,7 @@ function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) {
|
||||
madeInClient
|
||||
) => {
|
||||
const enableStudyLazyLoad = false;
|
||||
wadoDicomWebClient.headers = generateWadoHeader();
|
||||
wadoDicomWebClient.headers = generateWadoHeader(excludeTransferSyntax);
|
||||
// data is all SOPInstanceUIDs
|
||||
const data = await retrieveStudyMetadata(
|
||||
wadoDicomWebClient,
|
||||
@@ -484,7 +513,7 @@ function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) {
|
||||
returnPromises = false
|
||||
) => {
|
||||
const enableStudyLazyLoad = true;
|
||||
wadoDicomWebClient.headers = generateWadoHeader();
|
||||
wadoDicomWebClient.headers = generateWadoHeader(excludeTransferSyntax);
|
||||
// Get Series
|
||||
const { preLoadData: seriesSummaryMetadata, promises: seriesPromises } =
|
||||
await retrieveStudyMetadata(
|
||||
|
||||
Reference in new issue
Block a user