MCPcopy Create free account
hub / github.com/apache/trafficserver / BridgeFactory

Method BridgeFactory

src/cripts/Bundles/HRWBridge.cc:332–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330} // namespace detail
331
332detail::HRWBridge *
333cripts::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}

Callers

nothing calls this directly

Calls 6

remove_prefix_atMethod · 0.80
take_prefix_atMethod · 0.80
TSErrorFunction · 0.50
starts_withMethod · 0.45
ends_withMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected