Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize original transfer syntax when multiple accepts with no quality provided #2753

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

smithago
Copy link
Contributor

@smithago smithago commented Jun 2, 2023

Description

SLIM viewer sends multiple accept headers to get frames. Original is the last, this causes us to pick another accept and fail because today our code needs entire file to do transcoding and will throw when file size is greater than 100M.

This fix will make us prioritize picking original if available in the accept list.

Related issues

ImagingDataCommons/dicom-microscopy-viewer#95

Testing

Added unit tests

@smithago smithago requested a review from a team as a code owner June 2, 2023 00:18
@smithago smithago requested a review from jovinson-ms June 2, 2023 00:19
private static bool IsHigherPriorityTransferSyntax(AcceptHeader header, AcceptHeader selectedHeader)
{
bool isQualityGreater = (header.Quality ?? 0.000) >= (selectedHeader.Quality ?? 0.000);
return (header.TransferSyntax.Value == DicomTransferSyntaxUids.Original && isQualityGreater);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming is misleading: Original should really be called Any. If we want to prioritize the original, we should look up the original transfer syntax from the DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I am not seeing the difference. It is still saying the same without knowing the exact transfer syntax UID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic will prioritize the original syntax if the request specifies any transfer syntax for the media type via *.

However, if we have an image stored in Explicit VR Little Endian and a caller sends the following in the Accept header:

  • media type application/dicom, transfer syntax JPEG 2000, no qvalue
  • media type application/dicom, transfer syntax Explicit VR Little Endian, no qvalue

Then this tie-breaking logic will pick JPEG 2000 as the transfer syntax to return and we will transcode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The goal is not to avoid transcoding, it is to prioritize * when given in a list of media type with no q value

@smithago smithago merged commit e88f0c4 into main Jun 5, 2023
@smithago smithago deleted the personal/smithasa/media-type-ordering branch June 5, 2023 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants