aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-17 22:49:37 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-17 22:49:37 -0800
commit338706c2420ce3e51b546a6ba2574e10346a511b (patch)
tree6bcb07f219936e5780eecf683309660a810f8f3e /src
parent4c637fe5e4624eeaac55ed77deabdf427d2ba7a6 (diff)
downloadnng-338706c2420ce3e51b546a6ba2574e10346a511b.tar.gz
nng-338706c2420ce3e51b546a6ba2574e10346a511b.tar.bz2
nng-338706c2420ce3e51b546a6ba2574e10346a511b.zip
fixes #211 Restore handling of '*' in URL logic
Diffstat (limited to 'src')
-rw-r--r--src/core/url.c14
-rw-r--r--src/supplemental/http/http.h8
-rw-r--r--src/transport/tcp/tcp.c3
-rw-r--r--src/transport/tls/tls.c3
4 files changed, 22 insertions, 6 deletions
diff --git a/src/core/url.c b/src/core/url.c
index 7e1b61b5..1c3d6c83 100644
--- a/src/core/url.c
+++ b/src/core/url.c
@@ -283,6 +283,20 @@ nni_url_parse(nni_url **urlp, const char *raw)
}
}
+ // If the hostname part is just '*', skip over it. (We treat it
+ // as an empty host for legacy nanomsg compatibility. This may be
+ // non-RFC compliant, but we're really only interested in parsing
+ // nanomsg URLs. One weird side effect of this is that some URLS
+ // which would be invalid (ipc://*/bogus for example) will now parse
+ // to something that might be surprising (ipc:///bogus now), for
+ // example -- although in the IPC case the URL is *always* a local
+ // path without any host component.
+ if (((len == 1) && (s[0] == '*')) ||
+ ((len > 1) && (strncmp(s, "*:", 2) == 0))) {
+ s++;
+ len--;
+ }
+
if ((url->u_host = nni_alloc(len + 1)) == NULL) {
rv = NNG_ENOMEM;
goto error;
diff --git a/src/supplemental/http/http.h b/src/supplemental/http/http.h
index 47c8d654..4e2ac697 100644
--- a/src/supplemental/http/http.h
+++ b/src/supplemental/http/http.h
@@ -134,8 +134,12 @@ enum { NNI_HTTP_STATUS_CONTINUE = 100,
// the connection.
typedef struct nni_http nni_http;
-extern int nni_http_init_tcp(nni_http **, void *);
-extern int nni_http_init_tls(nni_http **, nng_tls_config *, void *);
+// These initialization functions create stream for HTTP transactions.
+// They should only be used by the server or client HTTP implementations,
+// and are not for use by other code.
+extern int nni_http_init_tcp(nni_http **, void *);
+extern int nni_http_init_tls(nni_http **, nng_tls_config *, void *);
+
extern void nni_http_close(nni_http *);
extern void nni_http_fini(nni_http *);
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index a361da53..9110e31c 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -564,8 +564,7 @@ nni_tcp_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
return (rv);
}
- if ((strlen(url->u_hostname) == 0) ||
- (strcmp(url->u_hostname, "*") == 0)) {
+ if (strlen(url->u_hostname) == 0) {
host = NULL;
} else {
host = url->u_hostname;
diff --git a/src/transport/tls/tls.c b/src/transport/tls/tls.c
index 9832c36c..753a1e75 100644
--- a/src/transport/tls/tls.c
+++ b/src/transport/tls/tls.c
@@ -580,8 +580,7 @@ nni_tls_ep_init(void **epp, const char *addr, nni_sock *sock, int mode)
return (rv);
}
- if ((strlen(url->u_hostname) == 0) ||
- (strcmp(url->u_hostname, "*") == 0)) {
+ if (strlen(url->u_hostname) == 0) {
host = NULL;
} else {
host = url->u_hostname;