diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-17 15:25:01 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-17 19:05:32 -0800 |
| commit | 47754eff45271d674fe6d347be82d6755195e8ce (patch) | |
| tree | 6952c9fba61900e51760cb954cab24acbfb1b454 /src/supplemental/http/http_client.c | |
| parent | 1ebbe9fd8612ed2794c06108d485819f2d1e03d5 (diff) | |
| download | nng-47754eff45271d674fe6d347be82d6755195e8ce.tar.gz nng-47754eff45271d674fe6d347be82d6755195e8ce.tar.bz2 nng-47754eff45271d674fe6d347be82d6755195e8ce.zip | |
fixes #1355 wss4 and wss6 don't work as they should
This also properly reenables the wssfile_test.
Diffstat (limited to 'src/supplemental/http/http_client.c')
| -rw-r--r-- | src/supplemental/http/http_client.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c index c420e1ff..2efb97a8 100644 --- a/src/supplemental/http/http_client.c +++ b/src/supplemental/http/http_client.c @@ -99,16 +99,28 @@ nni_http_client_init(nni_http_client **cp, const nni_url *url) { int rv; nni_http_client *c; - nng_url myurl; + nng_url my_url; // Rewrite URLs to either TLS or TCP. - memcpy(&myurl, url, sizeof(myurl)); + memcpy(&my_url, url, sizeof(my_url)); if ((strcmp(url->u_scheme, "http") == 0) || (strcmp(url->u_scheme, "ws") == 0)) { - myurl.u_scheme = "tcp"; + my_url.u_scheme = "tcp"; } else if ((strcmp(url->u_scheme, "https") == 0) || (strcmp(url->u_scheme, "wss") == 0)) { - myurl.u_scheme = "tls+tcp"; + my_url.u_scheme = "tls+tcp"; + } else if ((strcmp(url->u_scheme, "ws4") == 0) || + (strcmp(url->u_scheme, "http4") == 0)) { + my_url.u_scheme = "tcp4"; + } else if ((strcmp(url->u_scheme, "ws6") == 0) || + (strcmp(url->u_scheme, "http6") == 0)) { + my_url.u_scheme = "tcp6"; + } else if ((strcmp(url->u_scheme, "wss4") == 0) || + (strcmp(url->u_scheme, "https4") == 0)) { + my_url.u_scheme = "tls+tcp4"; + } else if ((strcmp(url->u_scheme, "wss6") == 0) || + (strcmp(url->u_scheme, "https6") == 0)) { + my_url.u_scheme = "tls+tcp6"; } else { return (NNG_EADDRINVAL); } @@ -124,7 +136,7 @@ nni_http_client_init(nni_http_client **cp, const nni_url *url) nni_mtx_init(&c->mtx); nni_aio_list_init(&c->aios); - if ((rv = nng_stream_dialer_alloc_url(&c->dialer, &myurl)) != 0) { + if ((rv = nng_stream_dialer_alloc_url(&c->dialer, &my_url)) != 0) { nni_http_client_fini(c); return (rv); } |
