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



##########
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:
       I don't know how lenient the url specification is with regards to 
whitespaces, if it does not allow them, I would not silently trim it, but log 
some errors




-- 
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