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

fix(wado-rs): can not decode some multipart properly #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Chinlinlee
Copy link
Member

@Chinlinlee Chinlinlee commented Mar 5, 2025

Describe what this pull request is trying to achieve

  • The wadorsloader not decode some multipart response properly

Additional notes and description of your changes

  • In this code snippet, it try to convert all buffer to string, as may exceeds max string length when encountering large data.

    let intArray = new Uint8Array(resBlob);
    let charArray = new Array(intArray.length);
    for (let i = 0; i < intArray.length; i++) charArray[i] = String.fromCodePoint(intArray[i]);
    let responseText = charArray.join('');

  • Here, acceptable headers are hardcode, and rereturing headers that are legal (e.g. Content-Location) will result in decoding failure

    function getStartIndex(responseText) {
    var fileStartIndex = [];
    let teststring = ["Content-Type", "Content-Length", "MIME-Version"]
    let matchesIndex;
    for (let type of teststring) {
    let contentTypeMatches = responseText.matchAll(new RegExp(`${type}.*[\r\n|\r|\n]$`, "gim"));
    for (let match of contentTypeMatches) {
    if (isNaN(match.index)) continue;
    if (!matchesIndex || (match.index > matchesIndex.index))
    matchesIndex = { index: match.index, length: match['0'].length };
    }
    }
    fileStartIndex.push(matchesIndex.index + matchesIndex.length + 3);
    return fileStartIndex;
    }

  • Use multipartDecode from dcmjs and it work properly

Environment this was tested in

  • OS: Windows 11 24H2
  • Browser: 132.0.6834.197

Test Details

  • Use serve to host bluelight in local
  • Open /bluelight/html/start?StudyInstanceUID=1.3.6.1.4.1.14519.5.2.1.1869.4002.216192212057343433620283048159
  • Display images fine

Related Issues

- Use `multipartDecode` from dcmjs
@cylien cylien added the bug Something isn't working label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants