comparison OrthancFramework/UnitTestsSources/RestApiTests.cpp @ 4333:a85e74235a78

fix parsing of multipart boundaries, to resolve issue #190 in STOW-RS of DICOMweb plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Nov 2020 06:57:23 +0100
parents 072adf3c3409
children 3af1d763763a
comparison
equal deleted inserted replaced
4332:17d209a3f397 4333:a85e74235a78
892 } 892 }
893 } 893 }
894 } 894 }
895 895
896 896
897 TEST(MultipartStreamReader, Issue190)
898 {
899 // https://bugs.orthanc-server.com/show_bug.cgi?id=190
900 // https://hg.orthanc-server.com/orthanc-dicomweb/rev/6dc2f79b5579
901
902 std::map<std::string, std::string> headers;
903 headers["content-type"] = "multipart/related; type=application/dicom; boundary=0f3cf5c0-70e0-41ef-baef-c6f9f65ec3e1";
904
905 {
906 std::string tmp, contentType, subType, boundary;
907 ASSERT_TRUE(Orthanc::MultipartStreamReader::GetMainContentType(tmp, headers));
908 ASSERT_TRUE(Orthanc::MultipartStreamReader::ParseMultipartContentType(contentType, subType, boundary, tmp));
909 ASSERT_EQ("multipart/related", contentType);
910 ASSERT_EQ("application/dicom", subType);
911 ASSERT_EQ("0f3cf5c0-70e0-41ef-baef-c6f9f65ec3e1", boundary);
912 }
913
914 headers["content-type"] = "multipart/related; type=\"application/dicom\"; boundary=\"0f3cf5c0-70e0-41ef-baef-c6f9f65ec3e1\"";
915
916 {
917 std::string tmp, contentType, subType, boundary;
918 ASSERT_TRUE(Orthanc::MultipartStreamReader::GetMainContentType(tmp, headers));
919 ASSERT_TRUE(Orthanc::MultipartStreamReader::ParseMultipartContentType(contentType, subType, boundary, tmp));
920 ASSERT_EQ("multipart/related", contentType);
921 ASSERT_EQ("application/dicom", subType);
922 ASSERT_EQ("0f3cf5c0-70e0-41ef-baef-c6f9f65ec3e1", boundary);
923 }
924 }
925
926
897 TEST(WebServiceParameters, Url) 927 TEST(WebServiceParameters, Url)
898 { 928 {
899 WebServiceParameters w; 929 WebServiceParameters w;
900 930
901 ASSERT_THROW(w.SetUrl("ssh://coucou"), OrthancException); 931 ASSERT_THROW(w.SetUrl("ssh://coucou"), OrthancException);