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

Method makePath

plugins/statichit/statichit.cc:88–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 ~StaticHitConfig() { TSContDestroy(cont); }
87
88 std::string_view
89 makePath(TSHttpTxn txnp, std::string &output) const
90 {
91 std::string_view ret = {};
92
93 if (!dirPath.empty()) {
94 TSMBuffer reqp;
95 TSMLoc hdr_loc = nullptr, url_loc = nullptr;
96
97 if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc)) {
98 if (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc)) {
99 int path_len = 0;
100 auto path = TSUrlPathGet(reqp, url_loc, &path_len);
101
102 std::filesystem::path requested_file_path(
103 std::filesystem::weakly_canonical(dirPath / std::string_view{path, static_cast<size_t>(path_len)}));
104
105 TSHandleMLocRelease(reqp, hdr_loc, url_loc);
106 TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
107
108 if (std::equal(dirPath.begin(), dirPath.end(), requested_file_path.begin()) &&
109 std::filesystem::is_regular_file(requested_file_path)) {
110 output = requested_file_path.string();
111 ret = {output.c_str(), output.size()};
112 }
113 } else {
114 TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
115 }
116 }
117 } else {
118 ret = filePath;
119 }
120
121 return ret;
122 }
123
124 std::filesystem::path dirPath;
125 std::string filePath;

Callers 1

Calls 11

TSHttpTxnClientReqGetFunction · 0.85
TSHttpHdrUrlGetFunction · 0.85
TSUrlPathGetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
is_regular_fileFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
stringMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected