| 330 | } // namespace detail |
| 331 | |
| 332 | detail::HRWBridge * |
| 333 | cripts::Bundle::Headers::BridgeFactory(const cripts::string &source) |
| 334 | { |
| 335 | cripts::string_view str = source; |
| 336 | |
| 337 | str.trim_if([](char c) { return std::isspace(c) || c == '"' || c == '\''; }); |
| 338 | |
| 339 | if (str.starts_with("%{") && str.ends_with("}")) { |
| 340 | str.remove_prefix_at('{'); |
| 341 | str.remove_suffix_at('}'); |
| 342 | |
| 343 | auto key = str.take_prefix_at(':'); |
| 344 | |
| 345 | if (key == "ID") { |
| 346 | return new detail::ID(str); |
| 347 | } else if (key == "IP") { |
| 348 | return new detail::IP(str); |
| 349 | } else if (key == "CIDR") { |
| 350 | return new detail::CIDR(str); |
| 351 | } else if (key == "FROM-URL") { |
| 352 | return new detail::URL(detail::URL::Type::REMAP_FROM, str); |
| 353 | } else if (key == "TO-URL") { |
| 354 | return new detail::URL(detail::URL::Type::REMAP_TO, str); |
| 355 | } else if (key == "CLIENT-URL") { |
| 356 | return new detail::URL(detail::URL::Type::CLIENT, str); |
| 357 | } else if (key == "CACHE-URL") { |
| 358 | return new detail::URL(detail::URL::Type::CACHE, str); |
| 359 | } else if (key == "PRISTINE-URL") { |
| 360 | return new detail::URL(detail::URL::Type::PRISTINE, str); |
| 361 | } else if (key == "NEXT-HOP") { |
| 362 | return new detail::URL(detail::URL::Type::PARENT, str); |
| 363 | // ToDo: Need proper support for URL: type here, which is a bit more complex (context sensitive) |
| 364 | } else { |
| 365 | TSError("[Cripts::Headers] Unknown HRWBridge key: %s.", key.data()); |
| 366 | } |
| 367 | } |
| 368 | // Always return the "raw" string if we don't have something special to do |
| 369 | return new detail::HRWBridge(source); |
| 370 | } |
nothing calls this directly
no test coverage detected