MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / UrlEncode

Method UrlEncode

tests/gtest/gtest-all.cc:5801–5818  ·  view source on GitHub ↗

Checks if str contains '=', '&', '%' or '\n' characters. If yes, replaces them by "%xx" where xx is their hexadecimal value. For example, replaces "=" with "%3D". This algorithm is O(strlen(str)) in both time and space -- important as the input str may contain an arbitrarily long test failure message and stack trace.

Source from the content-addressed store, hash-verified

5799// in both time and space -- important as the input str may contain an
5800// arbitrarily long test failure message and stack trace.
5801std::string StreamingListener::UrlEncode(const char* str) {
5802 std::string result;
5803 result.reserve(strlen(str) + 1);
5804 for (char ch = *str; ch != '\0'; ch = *++str) {
5805 switch (ch) {
5806 case '%':
5807 case '=':
5808 case '&':
5809 case '\n':
5810 result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
5811 break;
5812 default:
5813 result.push_back(ch);
5814 break;
5815 }
5816 }
5817 return result;
5818}
5819
5820void StreamingListener::SocketWriter::MakeConnection() {
5821 GTEST_CHECK_(sockfd_ == -1)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected