comparison OrthancFramework/Sources/HttpServer/HttpContentNegociation.cpp @ 5339:cb11e5ced4e3

added tests from issue #216
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Jun 2023 10:32:58 +0200
parents 78c59b02b121
children f41e1f635c4d
comparison
equal deleted inserted replaced
5338:78c59b02b121 5339:cb11e5ced4e3
64 { 64 {
65 private: 65 private:
66 const Handler& handler_; 66 const Handler& handler_;
67 uint8_t level_; 67 uint8_t level_;
68 float quality_; 68 float quality_;
69 std::string application_;
70 Dictionary parameters_; 69 Dictionary parameters_;
71 70
72 static float GetQuality(const Dictionary& parameters) 71 static float GetQuality(const Dictionary& parameters)
73 { 72 {
74 Dictionary::const_iterator found = parameters.find("q"); 73 Dictionary::const_iterator found = parameters.find("q");
109 const std::string& type, 108 const std::string& type,
110 const std::string& subtype, 109 const std::string& subtype,
111 const Dictionary& parameters) : 110 const Dictionary& parameters) :
112 handler_(handler), 111 handler_(handler),
113 quality_(GetQuality(parameters)), 112 quality_(GetQuality(parameters)),
114 application_(type + "/" + subtype),
115 parameters_(parameters) 113 parameters_(parameters)
116 { 114 {
117 if (type == "*" && subtype == "*") 115 if (type == "*" && subtype == "*")
118 { 116 {
119 level_ = 0; 117 level_ = 0;
246 Dictionary parameters; 244 Dictionary parameters;
247 for (size_t i = 1; i < tokens.size(); i++) 245 for (size_t i = 1; i < tokens.size(); i++)
248 { 246 {
249 std::string key, value; 247 std::string key, value;
250 248
251 if (!SplitPair(key, value, tokens[i], '=')) 249 if (SplitPair(key, value, tokens[i], '='))
250 {
251 // Remove the enclosing quotes, if present
252 if (!value.empty() &&
253 value[0] == '"' &&
254 value[value.size() - 1] == '"')
255 {
256 value = value.substr(1, value.size() - 2);
257 }
258 }
259 else
252 { 260 {
253 key = Toolbox::StripSpaces(tokens[i]); 261 key = Toolbox::StripSpaces(tokens[i]);
254 value = ""; 262 value = "";
255 } 263 }
256 264