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

Function parseQueryParameters

plugins/esi/combo_handler.cc:608–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608static void
609parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
610{
611 creq.status = TS_HTTP_STATUS_OK;
612 int param_start_pos = 0;
613 bool sig_verified = false;
614 int colon_pos = -1;
615 string file_url("http://localhost/");
616 size_t file_base_url_size = file_url.size();
617 const char *common_prefix = nullptr;
618 int common_prefix_size = 0;
619 const char *common_prefix_path = nullptr;
620 int common_prefix_path_size = 0;
621
622 for (int i = 0; i <= query_len; ++i) {
623 if ((i == query_len) || (query[i] == '&')) {
624 int param_len = i - param_start_pos;
625 if (param_len) {
626 const char *param = query + param_start_pos;
627 if ((param_len >= 4) && (strncmp(param, "sig=", 4) == 0)) {
628 if (SIG_KEY_NAME.size()) {
629 if (!param_start_pos) {
630 LOG_DEBUG("Signature cannot be the first parameter in query [%.*s]", query_len, query);
631 } else if (param_len == 4) {
632 LOG_DEBUG("Signature empty in query [%.*s]", query_len, query);
633 } else {
634 // TODO - really verify the signature
635 LOG_DEBUG("Verified signature successfully");
636 sig_verified = true;
637 }
638 if (!sig_verified) {
639 LOG_DEBUG("Signature [%.*s] on query [%.*s] is invalid", param_len - 4, param + 4, param_start_pos, query);
640 }
641 } else {
642 LOG_DEBUG("Verification not configured, ignoring signature");
643 }
644 break; // nothing useful after the signature
645 }
646 if ((param_len >= 2) && (param[0] == 'p') && (param[1] == '=')) {
647 common_prefix_size = param_len - 2;
648 common_prefix_path_size = 0;
649 if (common_prefix_size) {
650 common_prefix = param + 2;
651 for (int i = 0; i < common_prefix_size; ++i) {
652 if (common_prefix[i] == ':') {
653 common_prefix_path = common_prefix;
654 common_prefix_path_size = i;
655 ++i; // go beyond the ':'
656 common_prefix += i;
657 common_prefix_size -= i;
658 break;
659 }
660 }
661 }
662 LOG_DEBUG("Common prefix is [%.*s], common prefix path is [%.*s]", common_prefix_size, common_prefix,
663 common_prefix_path_size, common_prefix_path);
664 } else {
665 if (common_prefix_path_size) {

Callers 1

getClientRequestFunction · 0.85

Calls 6

sizeMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected