From 29d6c4ac04d4eb5c7eca295a77c8df47fb04f12f Mon Sep 17 00:00:00 2001
From: Marko Mikulicic <mkm@cesanta.com>
Date: Thu, 17 Mar 2016 12:52:07 +0100
Subject: [PATCH] Fix url path parsing

The url parser had two bugs:
- `http://example.com` -> `GET // HTTP/1.1`
- `foo://bar/baz` -> path is `"baz"` instead of `"/baz"`

Now the path returned by  `mg_http_common_url_parse` always
starts with `/`.

Closes cesanta/mongoose#631

PUBLISHED_FROM=f56ed97361ca14ee31d6ed26cf7afe5cd11e0dc5
---
 mongoose.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index bf81530ef..38883ccb3 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -7540,7 +7540,6 @@ static int mg_http_common_url_parse(const char *url, const char *schema,
       return -1;
     }
     if (*url == '/') {
-      url++;
       break;
     }
     if (*url == ':') *port_i = addr_len;
@@ -7632,7 +7631,7 @@ struct mg_connection *mg_connect_http(struct mg_mgr *mgr,
     /* If the port was addred by us, restore the original host. */
     if (port_i >= 0) addr[port_i] = '\0';
 
-    mg_printf(nc, "%s /%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %" SIZE_T_FMT
+    mg_printf(nc, "%s %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %" SIZE_T_FMT
                   "\r\n%s\r\n%s",
               post_data == NULL ? "GET" : "POST", path, addr,
               post_data == NULL ? 0 : strlen(post_data),
-- 
GitLab