| 342 | candidates.push_back("*"); // Rule 2. |
| 343 | |
| 344 | foreach (const string& candidate, candidates) { |
| 345 | // Is the candidate one of the accepted encodings? |
| 346 | foreach (const string& encoding_, strings::tokenize(accept.get(), ",")) { |
| 347 | vector<string> tokens = strings::tokenize(encoding_, ";"); |
| 348 | |
| 349 | if (tokens.empty()) { |
| 350 | continue; |
| 351 | } |
| 352 | |
| 353 | if (strings::lower(tokens[0]) == strings::lower(candidate)) { |
| 354 | // Is there a 0 q value? Ex: 'gzip;q=0.0'. |
| 355 | const map<string, vector<string>> values = |
| 356 | strings::pairs(encoding_, ";", "="); |
| 357 | |
| 358 | // Look for { "q": ["0"] }. |
| 359 | if (values.count("q") == 0 || values.find("q")->second.size() != 1) { |
| 360 | // No q value, or malformed q value. |
| 361 | return true; |
| 362 | } |
| 363 | |
| 364 | // Is the q value > 0? |
| 365 | Try<double> value = numify<double>(values.find("q")->second[0]); |
| 366 | return value.isSome() && value.get() > 0; |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | return false; |
| 372 | } |
nothing calls this directly
no test coverage detected