Browse Source

Merge pull request #11662 from mckellyln/hpcc-19208

HPCC-19208 CSmartSocketFactory ctor parse out http[s]://

Reviewed-By: Rodrigo Pastrana <rodrigo.pastrana@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 years ago
parent
commit
491ec1e841
1 changed files with 21 additions and 3 deletions
  1. 21 3
      system/jlib/jsmartsock.cpp

+ 21 - 3
system/jlib/jsmartsock.cpp

@@ -45,9 +45,27 @@ public:
         unsigned port = defport;
 
         char *saveptr;
-        char *ip = strtok_r(copyFullText, "|", &saveptr);
-        while (ip != NULL)
+        char *hostportstr = strtok_r(copyFullText, "|", &saveptr);
+        while (hostportstr != nullptr)
         {
+            // strip off http[s]://
+            // is strcasestr/stristr available ?
+            char *ip = strstr(hostportstr, "http://");
+            if (ip == nullptr)
+                ip = strstr(hostportstr, "HTTP://");
+            if (ip != nullptr)
+                ip += 7;
+            else
+            {
+                ip = strstr(hostportstr, "https://");
+                if (ip == nullptr)
+                    ip = strstr(hostportstr, "HTTPS://");
+                if (ip != nullptr)
+                    ip += 8;
+            }
+            if (ip == nullptr)
+                ip = hostportstr;
+
             char *p = strchr(ip, ':');
 
             if (p)
@@ -83,7 +101,7 @@ public:
             {
                 array.append(new SmartSocketEndpoint(ip, port));
             }
-            ip = strtok_r(NULL, "|", &saveptr);
+            hostportstr = strtok_r(NULL, "|", &saveptr);
         }
 
         free(copyFullText);