MCPcopy Create free account
hub / github.com/apache/impala / UrlEncode

Function UrlEncode

be/src/kudu/util/url-coding.cc:53–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51static std::function<bool (char)> ShouldNotEscape = boost::is_any_of("-_.~"); // NOLINT(*)
52
53static inline void UrlEncode(const char* in, int in_len, string* out, bool hive_compat) {
54 (*out).reserve(in_len);
55 std::ostringstream ss;
56 for (int i = 0; i < in_len; ++i) {
57 const char ch = in[i];
58 // Escape the character iff a) we are in Hive-compat mode and the
59 // character is in the Hive whitelist or b) we are not in
60 // Hive-compat mode, and the character is not alphanumeric or one
61 // of the four commonly excluded characters.
62 if ((hive_compat && HiveShouldEscape(ch)) ||
63 (!hive_compat && !(isalnum(ch) || ShouldNotEscape(ch)))) {
64 ss << '%' << std::uppercase << std::hex << static_cast<uint32_t>(ch);
65 } else {
66 ss << ch;
67 }
68 }
69
70 (*out) = ss.str();
71}
72
73void UrlEncode(const vector<uint8_t>& in, string* out, bool hive_compat) {
74 if (in.empty()) {

Callers 3

ThreadPathHandlerMethod · 0.70
UrlEncodeToStringFunction · 0.70
TestUrlFunction · 0.70

Calls 4

reserveMethod · 0.80
strMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

TestUrlFunction · 0.56