comparison OrthancFramework/Sources/HttpServer/HttpServer.cpp @ 4226:7bd5eab3ba25

prototyping IWebDavBucket
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 04 Oct 2020 13:23:53 +0200
parents 2d5209153b32
children 7fff7e683d65
comparison
equal deleted inserted replaced
4225:81f2d1484886 4226:7bd5eab3ba25
30 #include "../Logging.h" 30 #include "../Logging.h"
31 #include "../OrthancException.h" 31 #include "../OrthancException.h"
32 #include "../TemporaryFile.h" 32 #include "../TemporaryFile.h"
33 #include "HttpToolbox.h" 33 #include "HttpToolbox.h"
34 34
35 #if ORTHANC_ENABLE_PUGIXML == 1
36 # include "IWebDavBucket.h"
37 #endif
38
35 #if ORTHANC_ENABLE_MONGOOSE == 1 39 #if ORTHANC_ENABLE_MONGOOSE == 1
36 # include <mongoose.h> 40 # include <mongoose.h>
37 41
38 #elif ORTHANC_ENABLE_CIVETWEB == 1 42 #elif ORTHANC_ENABLE_CIVETWEB == 1
39 # include <civetweb.h> 43 # include <civetweb.h>
1095 1099
1096 1100
1097 HttpServer::~HttpServer() 1101 HttpServer::~HttpServer()
1098 { 1102 {
1099 Stop(); 1103 Stop();
1104
1105 #if ORTHANC_ENABLE_PUGIXML == 1
1106 for (WebDavBuckets::iterator it = webDavBuckets_.begin(); it != webDavBuckets_.end(); ++it)
1107 {
1108 assert(it->second != NULL);
1109 delete it->second;
1110 }
1111 #endif
1100 } 1112 }
1101 1113
1102 1114
1103 void HttpServer::SetPortNumber(uint16_t port) 1115 void HttpServer::SetPortNumber(uint16_t port)
1104 { 1116 {
1418 1430
1419 Stop(); 1431 Stop();
1420 requestTimeout_ = seconds; 1432 requestTimeout_ = seconds;
1421 LOG(INFO) << "Request timeout in the HTTP server is set to " << seconds << " seconds"; 1433 LOG(INFO) << "Request timeout in the HTTP server is set to " << seconds << " seconds";
1422 } 1434 }
1435
1436
1437 #if ORTHANC_ENABLE_PUGIXML == 1
1438 void HttpServer::Register(const std::vector<std::string>& root,
1439 IWebDavBucket* bucket)
1440 {
1441 std::unique_ptr<IWebDavBucket> protection(bucket);
1442
1443 if (bucket == NULL)
1444 {
1445 throw OrthancException(ErrorCode_NullPointer);
1446 }
1447
1448 std::string s = "/";
1449 for (size_t i = 0; i < root.size(); i++)
1450 {
1451 if (root[i].empty())
1452 {
1453 throw OrthancException(ErrorCode_ParameterOutOfRange, "An URI component cannot be empty");
1454 }
1455
1456 s += root[i];
1457 }
1458
1459 if (webDavBuckets_.find(s) != webDavBuckets_.end())
1460 {
1461 throw OrthancException(ErrorCode_ParameterOutOfRange,
1462 "Cannot register two WebDAV buckets at the same root: " + s);
1463 }
1464 else
1465 {
1466 webDavBuckets_[s] = protection.release();
1467 }
1468 }
1469 #endif
1423 } 1470 }