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.
| 5799 | // in both time and space -- important as the input str may contain an |
| 5800 | // arbitrarily long test failure message and stack trace. |
| 5801 | std::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 | |
| 5820 | void StreamingListener::SocketWriter::MakeConnection() { |
| 5821 | GTEST_CHECK_(sockfd_ == -1) |
nothing calls this directly
no outgoing calls
no test coverage detected