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

Function UrlDecode

be/src/util/coding-util.cc:100–124  ·  view source on GitHub ↗

Adapted from http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/ example/http/server3/request_handler.cpp See http://www.boost.org/LICENSE_1_0.txt for license for this method.

Source from the content-addressed store, hash-verified

98// example/http/server3/request_handler.cpp
99// See http://www.boost.org/LICENSE_1_0.txt for license for this method.
100bool UrlDecode(const string& in, string* out, bool hive_compat) {
101 out->clear();
102 out->reserve(in.size());
103 for (size_t i = 0; i < in.size(); ++i) {
104 if (in[i] == '%') {
105 if (i + 3 <= in.size()) {
106 int value = 0;
107 istringstream is(in.substr(i + 1, 2));
108 if (is >> hex >> value) {
109 (*out) += static_cast<char>(value);
110 i += 2;
111 } else {
112 return false;
113 }
114 } else {
115 return false;
116 }
117 } else if (!hive_compat && in[i] == '+') { // Hive does not encode ' ' as '+'
118 (*out) += ' ';
119 } else {
120 (*out) += in[i];
121 }
122 }
123 return true;
124}
125
126bool Base64EncodeBufLen(int64_t in_len, int64_t* out_max) {
127 // Base64 encoding turns every 3 bytes into 4 characters. If the length is not

Callers 3

BuildArgumentMapMethod · 0.70
TestUrlFunction · 0.70
ParseParamsFunction · 0.50

Calls 4

reserveMethod · 0.80
substrMethod · 0.80
clearMethod · 0.65
sizeMethod · 0.45

Tested by 1

TestUrlFunction · 0.56