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

Function testsForReqHdr

tests/gold_tests/pluginTest/tsapi/test_tsapi.cc:57–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55std::bitset<64> remap_mask;
56
57void
58testsForReqHdr(char const *desc, TSMBuffer hbuf, TSMLoc hloc)
59{
60 logFile << desc << ':' << std::endl;
61 logFile << "TSHttpHdrEffectiveUrlBufGet(): ";
62 int64_t url_length;
63
64 if (TSHttpHdrEffectiveUrlBufGet(hbuf, hloc, nullptr, 0, &url_length) != TS_SUCCESS) {
65 logFile << "sizing call failed " << std::endl;
66
67 } else if (0 == url_length) {
68 logFile << "zero URL length returned" << std::endl;
69
70 } else {
71 std::string s(url_length, '?');
72
73 s += "yada";
74
75 int64_t url_length2;
76
77 if (TSHttpHdrEffectiveUrlBufGet(hbuf, hloc, s.data(), url_length + 4, &url_length2) != TS_SUCCESS) {
78 logFile << "data-obtaining call failed" << std::endl;
79
80 } else if (url_length2 != url_length) {
81 logFile << "second size does not match first" << std::endl;
82
83 } else if (s.substr(url_length, 4) != "yada") {
84 logFile << "overwrite" << std::endl;
85
86 } else {
87 logFile << s.substr(0, url_length) << std::endl;
88 }
89 }
90 logFile << "TSUrlSchemeGet(): ";
91 TSMLoc url_loc;
92 if (TSHttpHdrUrlGet(hbuf, hloc, &url_loc) != TS_SUCCESS) {
93 logFile << "failed to get URL loc" << std::endl;
94
95 } else {
96 ts::PostScript ps([=]() -> void { TSHandleMLocRelease(hbuf, TS_NULL_MLOC, url_loc); });
97
98 int scheme_len;
99 char const *scheme_data = TSUrlSchemeGet(hbuf, url_loc, &scheme_len);
100 if (!scheme_data || !scheme_len) {
101 logFile << "failed to get URL scheme" << std::endl;
102 } else {
103 logFile << std::string_view(scheme_data, scheme_len) << std::endl;
104 }
105 logFile << "TSUrlRawSchemeGet(): ";
106 scheme_data = TSUrlRawSchemeGet(hbuf, url_loc, &scheme_len);
107 if (!scheme_data || !scheme_len) {
108 logFile << "failed to get raw URL scheme" << std::endl;
109 } else {
110 logFile << std::string_view(scheme_data, scheme_len) << std::endl;
111 }
112 logFile << "TSUrlPortGet(): " << TSUrlPortGet(hbuf, url_loc) << std::endl;
113 logFile << "TSUrlRawPortGet(): " << TSUrlRawPortGet(hbuf, url_loc) << std::endl;
114 }

Callers 3

testsForReadReqHdrHookFunction · 0.85
testsForSendReqHdrHookFunction · 0.85
TSRemapDoRemapFunction · 0.85

Calls 9

TSHttpHdrUrlGetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSUrlSchemeGetFunction · 0.85
TSUrlRawSchemeGetFunction · 0.85
TSUrlPortGetFunction · 0.85
TSUrlRawPortGetFunction · 0.85
dataMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected