diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 8ef3bad4..7cdc3338 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1184,8 +1184,9 @@ lws_check_utf8(unsigned char *state, unsigned char *buf, size_t len) } /** - * lws_parse_uri: cut up https:/xxx:yyy/zzz into pieces + * lws_parse_uri: cut up prot:/ads:port/path into pieces * Notice it does so by dropping '\0' into input string + * and the leading / on the path is consequently lost * * @p: incoming uri string.. will get written to * @prot: result pointer for protocol part (https://) diff --git a/test-server/test-client.c b/test-server/test-client.c index 1222cccb..709f0b2e 100644 --- a/test-server/test-client.c +++ b/test-server/test-client.c @@ -274,7 +274,8 @@ int main(int argc, char **argv) struct lws_context_creation_info info; struct lws_client_connect_info i; struct lws_context *context; - const char *prot; + const char *prot, *p; + char path[300]; memset(&info, 0, sizeof info); @@ -323,12 +324,18 @@ int main(int argc, char **argv) memset(&i, 0, sizeof(i)); i.port = port; - if (lws_parse_uri(argv[optind], &prot, &i.address, &i.port, &i.path)) + if (lws_parse_uri(argv[optind], &prot, &i.address, &i.port, &p)) goto usage; - if (!strcmp(prot, "http://") || !strcmp(prot, "ws://")) + /* add back the leading / on path */ + path[0] = '/'; + strncpy(path + 1, p, sizeof(path) - 2); + path[sizeof(path) - 1] = '\0'; + i.path = path; + + if (!strcmp(prot, "http") || !strcmp(prot, "ws")) use_ssl = 0; - if (!strcmp(prot, "https://") || !strcmp(prot, "wss://")) + if (!strcmp(prot, "https") || !strcmp(prot, "wss")) use_ssl = 1; /*