MCPcopy Create free account
hub / github.com/apache/mesos / encode

Function encode

3rdparty/libprocess/src/http.cpp:848–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846
847
848string encode(const string& s, const string& additional_chars)
849{
850 ostringstream out;
851
852 foreach (unsigned char c, s) {
853 switch (c) {
854 // Reserved characters.
855 case '$':
856 case '&':
857 case '+':
858 case ',':
859 case '/':
860 case ':':
861 case ';':
862 case '=':
863 case '?':
864 case '@':
865 // Unsafe characters.
866 case ' ':
867 case '"':
868 case '<':
869 case '>':
870 case '#':
871 case '%':
872 case '{':
873 case '}':
874 case '|':
875 case '\\':
876 case '^':
877 case '~':
878 case '[':
879 case ']':
880 case '`':
881 // NOTE: The cast to unsigned int is needed.
882 out << '%' << std::setfill('0') << std::setw(2) << std::hex
883 << std::uppercase << (unsigned int) c;
884 break;
885 default:
886 // ASCII control characters and non-ASCII characters.
887 // NOTE: The cast to unsigned int is needed.
888 if (c < 0x20 ||
889 c > 0x7F ||
890 additional_chars.find_first_of(c) != string::npos) {
891 out << '%' << std::setfill('0') << std::setw(2) << std::hex
892 << std::uppercase << (unsigned int) c;
893 } else {
894 out << c;
895 }
896 break;
897 }
898 }
899
900 return out.str();
901}
902
903
904Try<string> decode(const string& s)

Callers 10

foreachpairFunction · 0.70
http.cppFile · 0.70
sendMethod · 0.70
MessageEncoderMethod · 0.70
HttpResponseEncoderMethod · 0.70
TEST_FFunction · 0.50
TEST_PFunction · 0.50
TEST_FFunction · 0.50
mainFunction · 0.50
TESTFunction · 0.50

Calls 15

SomeFunction · 0.85
loopFunction · 0.85
NoneClass · 0.85
readerMethod · 0.80
writerMethod · 0.80
removeFunction · 0.50
joinFunction · 0.50
stringifyClass · 0.50
BreakFunction · 0.50
ContinueClass · 0.50
emptyMethod · 0.45
isSomeMethod · 0.45

Tested by 5

TEST_FFunction · 0.40
TEST_PFunction · 0.40
TEST_FFunction · 0.40
mainFunction · 0.40
TESTFunction · 0.40