fgerlits commented on a change in pull request #1046:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1046#discussion_r619008212



##########
File path: libminifi/src/utils/HTTPClient.cpp
##########
@@ -15,8 +15,43 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "utils/HTTPClient.h"
+#include <algorithm>
 #include <string>
+
+#include "utils/HTTPClient.h"
+#include "utils/StringUtils.h"
+
+namespace {
+
+constexpr const char* HTTP = "http://";;
+constexpr const char* HTTPS = "https://";;
+
+utils::optional<std::string> parseProtocol(const std::string& url_input) {
+  if (utils::StringUtils::startsWith(url_input, HTTP)) {
+    return HTTP;
+  } else if (utils::StringUtils::startsWith(url_input, HTTPS)) {
+    return HTTPS;
+  } else {
+    return {};
+  }
+}
+
+utils::optional<int> parsePortNumber(const std::string& port_string) {
+  try {
+    size_t pos;
+    int port = std::stoi(port_string, &pos);
+    if (pos == port_string.size()) {

Review comment:
       Yes, there may be extra whitespace around the URL in the properties 
file.  This was already trimmed in `RemoteProcessorGroupPort.h`; I have added 
trimming in the other place where this code is used, `C2Agent.cpp`: 
https://github.com/apache/nifi-minifi-cpp/pull/1046/commits/d81d0d5ca59bb90410d45ce271470bab47246ea2.
   
   I agree that we probably don't want to allow URLs like `http://some.host: 
123 /some_path`.  In this case, we will log an error in the constructor of 
`URL` (line 115).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to