MCPcopy Create free account
hub / github.com/apache/arrow / ParseCookieAttribute

Method ParseCookieAttribute

cpp/src/arrow/flight/cookie_internal.cc:142–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142CookiePair Cookie::ParseCookieAttribute(const std::string& cookie_header_value,
143 std::string::size_type* start_pos) {
144 std::string::size_type equals_pos = cookie_header_value.find('=', *start_pos);
145 if (std::string::npos == equals_pos) {
146 // No cookie attribute.
147 *start_pos = std::string::npos;
148 return std::nullopt;
149 }
150
151 std::string::size_type semi_col_pos = cookie_header_value.find(';', equals_pos);
152 std::string out_key = arrow::internal::TrimString(
153 cookie_header_value.substr(*start_pos, equals_pos - *start_pos));
154 std::string out_value;
155 if (std::string::npos == semi_col_pos) {
156 // Last item - set start pos to end
157 out_value = arrow::internal::TrimString(cookie_header_value.substr(equals_pos + 1));
158 *start_pos = std::string::npos;
159 } else {
160 out_value = arrow::internal::TrimString(
161 cookie_header_value.substr(equals_pos + 1, semi_col_pos - equals_pos - 1));
162 *start_pos = semi_col_pos + 1;
163 }
164
165 // Key/Value may be URI-encoded.
166 out_key = arrow::util::UriUnescape(out_key);
167 out_value = arrow::util::UriUnescape(out_value);
168
169 // Strip outer quotes on the value.
170 if (out_value.size() >= 2 && out_value[0] == '"' &&
171 out_value[out_value.size() - 1] == '"') {
172 out_value = out_value.substr(1, out_value.size() - 2);
173 }
174
175 // Update the start position for subsequent calls to this function.
176 return std::make_pair(out_key, out_value);
177}
178
179void Cookie::ConvertCookieDate(std::string* date) {
180 // Abbreviated months in order.

Callers

nothing calls this directly

Calls 5

TrimStringFunction · 0.85
UriUnescapeFunction · 0.85
substrMethod · 0.80
findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected