Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 204x 15892x 15892x 15892x 15892x 15892x 15892x 15892x 15892x 15892x 15892x 15892x 47676x 15892x 15892x 31784x 15892x 15892x 15892x 15892x 204x | const generateAcceptHeader = (
configAcceptHeader: string[] = [],
requestTransferSyntaxUID = '*', //default to accept all transfer syntax
omitQuotationForMultipartRequest = false
): string[] => {
//if acceptedHeader is passed by config use it as it.
Iif (configAcceptHeader.length > 0) {
return configAcceptHeader;
}
let acceptHeader = ['multipart/related'];
let hasTransferSyntax = false;
if (requestTransferSyntaxUID && typeForTS[requestTransferSyntaxUID]) {
const type = typeForTS[requestTransferSyntaxUID];
acceptHeader.push('type=' + type);
acceptHeader.push('transfer-syntax=' + requestTransferSyntaxUID);
hasTransferSyntax = true;
} else E{
acceptHeader.push('type=application/octet-stream');
}
Iif (!hasTransferSyntax) {
acceptHeader.push('transfer-syntax=*');
}
if (!omitQuotationForMultipartRequest) {
//need to add quotation for each mime type of each accept entry
acceptHeader = acceptHeader.map(mime => {
if (mime.startsWith('type=')) {
const quotedParam = 'type="' + mime.substring(5, mime.length) + '"';
return quotedParam;
}
if (mime.startsWith('transfer-syntax=')) {
const quotedParam = 'transfer-syntax="' + mime.substring(16, mime.length) + '"';
return quotedParam;
} else {
return mime;
}
});
}
return [acceptHeader.join('; ')];
};
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',
};
export default generateAcceptHeader;
|