lws_parse_uri fix test client use and add more docs

https://github.com/warmcat/libwebsockets/issues/414

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-02-07 07:28:21 +08:00
parent 99e876d8f7
commit d2c140c8ed
2 changed files with 13 additions and 5 deletions

View file

@ -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://)

View file

@ -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;
/*