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

Method YAMLLoadMethod

src/proxy/IPAllow.cc:332–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332swoc::Errata
333IpAllow::YAMLLoadMethod(const YAML::Node &node, Record &rec)
334{
335 swoc::TextView value{node.Scalar()};
336 swoc::Vectray<swoc::TextView, 8> names;
337 // Process a single token. Required to deal with the variable number of tokens.
338 auto parse_method = [&](swoc::TextView value) -> void {
339 if (0 == strcasecmp(value, YAML_VALUE_METHODS_ALL)) {
340 rec._method_mask = ALL_METHOD_MASK;
341 } else {
342 int method_idx = hdrtoken_tokenize(value.data(), value.size());
343 if (HTTP_WKSIDX_CONNECT <= method_idx && method_idx < HTTP_WKSIDX_CONNECT + HTTP_WKSIDX_METHODS_CNT) {
344 rec._method_mask |= ACL::MethodIdxToMask(method_idx);
345 } else {
346 names.push_back(value);
347 Dbg(dbg_ctl_ip_allow, "Found nonstandard method '%.*s' at line %d", int(value.size()), value.data(), node.Mark().line);
348 }
349 }
350 };
351
352 if (node.IsScalar()) {
353 parse_method(swoc::TextView(node.Scalar()));
354 } else if (node.IsSequence()) {
355 for (auto const &elt : node) {
356 if (elt.IsScalar()) {
357 parse_method(swoc::TextView(elt.Scalar()));
358 if (rec._method_mask == ALL_METHOD_MASK) {
359 break; // we're done here, nothing else matters.
360 }
361 } else {
362 return swoc::Errata(ERRATA_ERROR, "{} {} - item ignored, all values for '{}' must be strings.", this, elt.Mark(),
363 YAML_TAG_METHODS);
364 }
365 }
366 } else {
367 return swoc::Errata(ERRATA_ERROR, "{} {} - item ignored, value for '{}' must be a single string or a list of strings.", this,
368 node.Mark(), YAML_TAG_METHODS);
369 }
370
371 // copy over to local memory if it's not all methods and there are non-standard ones.
372 if (rec._method_mask != ALL_METHOD_MASK && !names.empty()) {
373 rec._nonstandard_methods = _arena.alloc_span<swoc::TextView>(names.size());
374 for (unsigned idx = 0; idx < names.size(); ++idx) {
375 rec._nonstandard_methods[idx] = this->localize(names[idx]);
376 }
377 }
378 return {};
379}
380
381swoc::Errata
382IpAllow::YAMLLoadIPAddrRange(const YAML::Node &node, IpMap *map, IpAllow::Record const *record)

Callers 1

YAMLLoadEntryMethod · 0.95

Calls 11

localizeMethod · 0.95
strcasecmpFunction · 0.85
hdrtoken_tokenizeFunction · 0.85
TextViewClass · 0.85
ErrataClass · 0.85
ScalarMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
MarkMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected