comparison OrthancServer/Sources/main.cpp @ 4227:7fff7e683d65

basic implementation of WebDAV handler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Oct 2020 10:55:24 +0200
parents 7bd5eab3ba25
children c8c0bbaaace3
comparison
equal deleted inserted replaced
4226:7bd5eab3ba25 4227:7fff7e683d65
622 DummyBucket(ServerContext& context) : 622 DummyBucket(ServerContext& context) :
623 context_(context) 623 context_(context)
624 { 624 {
625 } 625 }
626 626
627 virtual bool IsExistingFolder(const std::vector<std::string>& path) ORTHANC_OVERRIDE
628 {
629 return (path.size() == 0 ||
630 (path.size() == 1 && path[0] == "Folder1") ||
631 (path.size() == 2 && path[0] == "Folder1" && path[1] == "Folder2"));
632 }
633
627 virtual bool ListCollection(Collection& collection, 634 virtual bool ListCollection(Collection& collection,
628 const UriComponents& path) ORTHANC_OVERRIDE 635 const UriComponents& path) ORTHANC_OVERRIDE
629 { 636 {
630 if (path.size() == 0 || 637 if (IsExistingFolder(path))
631 (path.size() == 1 && path[0] == "Folder1") ||
632 (path.size() == 2 && path[0] == "Folder1" && path[1] == "Folder2"))
633 { 638 {
634 for (unsigned int i = 0; i < 5; i++) 639 for (unsigned int i = 0; i < 5; i++)
635 { 640 {
636 std::unique_ptr<File> f(new File("IM" + boost::lexical_cast<std::string>(i) + ".dcm")); 641 std::unique_ptr<File> f(new File("IM" + boost::lexical_cast<std::string>(i) + ".dcm"));
637 f->SetContentLength(1024 * i); 642 f->SetContentLength(1024 * i);
643 f->SetMimeType(MimeType_PlainText);
638 collection.AddResource(f.release()); 644 collection.AddResource(f.release());
639 } 645 }
640 646
641 for (unsigned int i = 0; i < 5; i++) 647 for (unsigned int i = 0; i < 5; i++)
642 { 648 {
1104 httpServer.SetHttpExceptionFormatter(exceptionFormatter); 1110 httpServer.SetHttpExceptionFormatter(exceptionFormatter);
1105 httpServer.Register(context.GetHttpHandler()); 1111 httpServer.Register(context.GetHttpHandler());
1106 1112
1107 { 1113 {
1108 std::vector<std::string> root; // TODO 1114 std::vector<std::string> root; // TODO
1109 root.push_back("davfs"); 1115 root.push_back("a");
1116 root.push_back("b");
1110 httpServer.Register(root, new DummyBucket(context)); 1117 httpServer.Register(root, new DummyBucket(context));
1111 } 1118 }
1112 1119
1113 if (httpServer.GetPortNumber() < 1024) 1120 if (httpServer.GetPortNumber() < 1024)
1114 { 1121 {