Mercurial > hg > orthanc
annotate OrthancFramework/Sources/HttpServer/HttpContentNegociation.h @ 4792:434843934307 storage-cache
Added a StorageCache in the StorageAccessor
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 30 Sep 2021 12:14:19 +0200 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
rev | line source |
---|---|
1783 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1783 | 4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1783 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
1783 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
1783 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1783 | 20 **/ |
21 | |
22 #pragma once | |
23 | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
24 #include "../OrthancFramework.h" |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
25 #include "../Compatibility.h" |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
26 |
1783 | 27 #include <memory> |
28 #include <boost/noncopyable.hpp> | |
29 #include <map> | |
30 #include <list> | |
31 #include <string> | |
32 #include <vector> | |
33 #include <stdint.h> | |
34 | |
35 | |
36 namespace Orthanc | |
37 { | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
38 class ORTHANC_PUBLIC HttpContentNegociation : public boost::noncopyable |
1783 | 39 { |
40 public: | |
41 typedef std::map<std::string, std::string> HttpHeaders; | |
42 | |
43 class IHandler : public boost::noncopyable | |
44 { | |
45 public: | |
46 virtual ~IHandler() | |
47 { | |
48 } | |
49 | |
50 virtual void Handle(const std::string& type, | |
51 const std::string& subtype) = 0; | |
52 }; | |
53 | |
54 private: | |
55 struct Handler | |
56 { | |
57 std::string type_; | |
58 std::string subtype_; | |
59 IHandler& handler_; | |
60 | |
61 Handler(const std::string& type, | |
62 const std::string& subtype, | |
63 IHandler& handler); | |
64 | |
65 bool IsMatch(const std::string& type, | |
66 const std::string& subtype) const; | |
67 | |
68 void Call() const | |
69 { | |
70 handler_.Handle(type_, subtype_); | |
71 } | |
72 }; | |
73 | |
74 | |
75 struct Reference; | |
76 | |
77 typedef std::vector<std::string> Tokens; | |
78 typedef std::list<Handler> Handlers; | |
79 | |
80 Handlers handlers_; | |
81 | |
82 | |
83 static bool SplitPair(std::string& first /* out */, | |
84 std::string& second /* out */, | |
85 const std::string& source, | |
86 char separator); | |
87 | |
88 static float GetQuality(const Tokens& parameters); | |
89 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
90 static void SelectBestMatch(std::unique_ptr<Reference>& best, |
1783 | 91 const Handler& handler, |
92 const std::string& type, | |
93 const std::string& subtype, | |
94 float quality); | |
95 | |
96 public: | |
97 void Register(const std::string& mime, | |
98 IHandler& handler); | |
99 | |
100 bool Apply(const HttpHeaders& headers); | |
101 | |
102 bool Apply(const std::string& accept); | |
103 }; | |
104 } |