annotate OrthancFramework/Sources/HttpServer/HttpContentNegociation.cpp @ 5858:66fd63b8601e find-refactoring tip

StorageAccessOnFind: cont
author Alain Mazy <am@orthanc.team>
date Mon, 04 Nov 2024 22:34:14 +0100
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1783
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5344
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * the License, or (at your option) any later version.
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * 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
17 * Lesser General Public License for more details.
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
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
19 * 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
20 * 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
21 * <http://www.gnu.org/licenses/>.
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 **/
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../PrecompiledHeaders.h"
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "HttpContentNegociation.h"
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "../Logging.h"
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../OrthancException.h"
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include "../Toolbox.h"
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <boost/lexical_cast.hpp>
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Orthanc
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 HttpContentNegociation::Handler::Handler(const std::string& type,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 const std::string& subtype,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 IHandler& handler) :
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 type_(type),
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 subtype_(subtype),
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 handler_(handler)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 bool HttpContentNegociation::Handler::IsMatch(const std::string& type,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 const std::string& subtype) const
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (type == "*" && subtype == "*")
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 return true;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
53 else if (subtype == "*" && type == type_)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return true;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
57 else
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
58 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
59 return type == type_ && subtype == subtype_;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
60 }
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
64 class HttpContentNegociation::Reference : public boost::noncopyable
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
66 private:
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 const Handler& handler_;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 uint8_t level_;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 float quality_;
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
70 Dictionary parameters_;
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
72 static float GetQuality(const Dictionary& parameters)
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
73 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
74 Dictionary::const_iterator found = parameters.find("q");
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
75
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
76 if (found != parameters.end())
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
77 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
78 float quality;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
79 bool ok = false;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
80
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
81 try
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
82 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
83 quality = boost::lexical_cast<float>(found->second);
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
84 ok = (quality >= 0.0f && quality <= 1.0f);
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
85 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
86 catch (boost::bad_lexical_cast&)
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
87 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
88 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
89
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
90 if (ok)
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
91 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
92 return quality;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
93 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
94 else
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
95 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
96 throw OrthancException(
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
97 ErrorCode_BadRequest,
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
98 "Quality parameter out of range in a HTTP request (must be between 0 and 1): " + found->second);
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
99 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
100 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
101 else
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
102 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
103 return 1.0f; // Default quality
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
104 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
105 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
106
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
107 public:
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 Reference(const Handler& handler,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const std::string& type,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 const std::string& subtype,
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
111 const Dictionary& parameters) :
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 handler_(handler),
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
113 quality_(GetQuality(parameters)),
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
114 parameters_(parameters)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 if (type == "*" && subtype == "*")
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 level_ = 0;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 else if (subtype == "*")
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 level_ = 1;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 else
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 level_ = 2;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
129
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
130 void Call() const
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
131 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
132 handler_.Call(parameters_);
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
133 }
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 bool operator< (const Reference& other) const
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 if (level_ < other.level_)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 return true;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
141 else if (level_ > other.level_)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 return false;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 }
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
145 else
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
146 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
147 return quality_ < other.quality_;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
148 }
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 };
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 bool HttpContentNegociation::SplitPair(std::string& first /* out */,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 std::string& second /* out */,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 const std::string& source,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 char separator)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 size_t pos = source.find(separator);
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (pos == std::string::npos)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 return false;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 else
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 first = Toolbox::StripSpaces(source.substr(0, pos));
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 second = Toolbox::StripSpaces(source.substr(pos + 1));
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 return true;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
173 void HttpContentNegociation::SelectBestMatch(std::unique_ptr<Reference>& target,
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 const Handler& handler,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 const std::string& type,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 const std::string& subtype,
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
177 const Dictionary& parameters)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
179 std::unique_ptr<Reference> match(new Reference(handler, type, subtype, parameters));
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
181 if (target.get() == NULL ||
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
182 *target < *match)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
184 #if __cplusplus < 201103L
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
185 target.reset(match.release());
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
186 #else
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
187 target = std::move(match);
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
188 #endif
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 void HttpContentNegociation::Register(const std::string& mime,
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 IHandler& handler)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 std::string type, subtype;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 if (SplitPair(type, subtype, mime, '/') &&
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 type != "*" &&
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 subtype != "*")
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 handlers_.push_back(Handler(type, subtype, handler));
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 else
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 throw OrthancException(ErrorCode_ParameterOutOfRange);
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
211 bool HttpContentNegociation::Apply(const Dictionary& headers)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
213 Dictionary::const_iterator accept = headers.find("accept");
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 if (accept != headers.end())
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 return Apply(accept->second);
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 else
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 return Apply("*/*");
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 bool HttpContentNegociation::Apply(const std::string& accept)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 // https://en.wikipedia.org/wiki/Content_negotiation
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 // http://www.newmediacampaigns.com/blog/browser-rest-http-accept-headers
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 Tokens mediaRanges;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 Toolbox::TokenizeString(mediaRanges, accept, ',');
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
234 std::unique_ptr<Reference> bestMatch;
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 for (Tokens::const_iterator it = mediaRanges.begin();
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 it != mediaRanges.end(); ++it)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
239 Tokens tokens;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
240 Toolbox::TokenizeString(tokens, *it, ';');
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
242 if (tokens.size() > 0)
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
244 Dictionary parameters;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
245 for (size_t i = 1; i < tokens.size(); i++)
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
246 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
247 std::string key, value;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
248
5339
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
249 if (SplitPair(key, value, tokens[i], '='))
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
250 {
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
251 // Remove the enclosing quotes, if present
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
252 if (!value.empty() &&
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
253 value[0] == '"' &&
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
254 value[value.size() - 1] == '"')
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
255 {
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
256 value = value.substr(1, value.size() - 2);
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
257 }
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
258 }
cb11e5ced4e3 added tests from issue 216
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5338
diff changeset
259 else
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
260 {
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
261 key = Toolbox::StripSpaces(tokens[i]);
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
262 value = "";
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
263 }
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
265 parameters[key] = value;
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
266 }
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
267
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 std::string type, subtype;
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
269 if (SplitPair(type, subtype, tokens[0], '/'))
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 for (Handlers::const_iterator it2 = handlers_.begin();
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 it2 != handlers_.end(); ++it2)
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 if (it2->IsMatch(type, subtype))
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
276 SelectBestMatch(bestMatch, *it2, type, subtype, parameters);
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 if (bestMatch.get() == NULL) // No match was found
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 {
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 return false;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 else
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
5338
78c59b02b121 accept parameters are now provided to HttpContentNegociation::IHandler::Handle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
289 bestMatch->Call();
1783
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 return true;
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
dbb07eb1a2f3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }