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

Function parse_http_status_code_list

src/proxy/http/HttpConfig.cc:644–665  ·  view source on GitHub ↗

Parse list of HTTP status code and return HttpStatusBitset - e.g. "204 305 403 404 414 500 501 502 503 504" */

Source from the content-addressed store, hash-verified

642 - e.g. "204 305 403 404 414 500 501 502 503 504"
643 */
644static HttpStatusBitset
645parse_http_status_code_list(swoc::TextView status_list)
646{
647 HttpStatusBitset set;
648
649 auto is_sep{[](char c) { return isspace(c) || ',' == c || ';' == c; }};
650
651 while (!status_list.ltrim_if(is_sep).empty()) {
652 swoc::TextView span;
653 swoc::TextView token{status_list.take_prefix_if(is_sep)};
654 auto n = swoc::svtoi(token, &span);
655 if (span.size() != token.size()) {
656 Error("Invalid status code '%.*s': not a number", static_cast<int>(token.size()), token.data());
657 } else if (n <= 0 || n >= HTTP_STATUS_NUMBER) {
658 Error("Invalid status code '%.*s': out of range", static_cast<int>(token.size()), token.data());
659 } else {
660 set[n] = true;
661 }
662 }
663
664 return set;
665}
666
667static bool
668set_negative_caching_list(const char *name, RecDataT dtype, RecData data, HttpConfigParams *c, bool update)

Callers 2

Calls 6

svtoiFunction · 0.85
take_prefix_ifMethod · 0.80
ErrorClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected