Make mg_url_port() return 80 for ws://

This commit is contained in:
cpq
2021-01-18 18:39:22 +00:00
parent 30d86928d5
commit d83e547fa9
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -3634,7 +3634,7 @@ const char *mg_url_uri(const char *url) {
unsigned short mg_url_port(const char *url) {
struct url u = urlparse(url);
unsigned short port = 0;
if (memcmp(url, "http:", 5) == 0) port = 80;
if (memcmp(url, "http:", 5) == 0 || memcmp(url, "ws:", 3) == 0) port = 80;
if (memcmp(url, "wss:", 4) == 0 || memcmp(url, "https:", 6) == 0) port = 443;
if (memcmp(url, "mqtt:", 5) == 0) port = 1883;
if (memcmp(url, "mqtts:", 6) == 0) port = 8883;
+1 -1
View File
@@ -59,7 +59,7 @@ const char *mg_url_uri(const char *url) {
unsigned short mg_url_port(const char *url) {
struct url u = urlparse(url);
unsigned short port = 0;
if (memcmp(url, "http:", 5) == 0) port = 80;
if (memcmp(url, "http:", 5) == 0 || memcmp(url, "ws:", 3) == 0) port = 80;
if (memcmp(url, "wss:", 4) == 0 || memcmp(url, "https:", 6) == 0) port = 443;
if (memcmp(url, "mqtt:", 5) == 0) port = 1883;
if (memcmp(url, "mqtts:", 6) == 0) port = 8883;