diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-01-22 14:05:10 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-01-22 17:11:58 -0800 |
| commit | 3d075fad7496ec126c5087d1c36ab7a4af73ce16 (patch) | |
| tree | c5b5d6fe44eaa2996310683b5080de87160b9b41 /src/core/url.c | |
| parent | 5b1a3af7be4ae712868ae84b9a7d5a974d272b16 (diff) | |
| download | nng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.tar.gz nng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.tar.bz2 nng-3d075fad7496ec126c5087d1c36ab7a4af73ce16.zip | |
fixes #219 transports should take URL structure instead of string address
This eliminates a bunch of redundant URL parsing, using the common
URL logic we already have in place.
While here I fixed a problem with the TLS and WSS test suites that
was failing on older Ubuntu -- apparently older versions of mbedTLS
were unhappy if selecting OPTIONAL verification without a validate
certificate chain.
Diffstat (limited to 'src/core/url.c')
| -rw-r--r-- | src/core/url.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core/url.c b/src/core/url.c index a5b4fd06..3d8898bd 100644 --- a/src/core/url.c +++ b/src/core/url.c @@ -453,4 +453,31 @@ nni_url_free(nni_url *url) nni_strfree(url->u_fragment); nni_strfree(url->u_rawpath); NNI_FREE_STRUCT(url); +} + +int +nni_url_clone(nni_url **dstp, const nni_url *src) +{ + nni_url *dst; + + if ((dst = NNI_ALLOC_STRUCT(dst)) == NULL) { + return (NNG_ENOMEM); + } +#define URL_COPYSTR(d, s) ((s != NULL) && ((d = nni_strdup(s)) == NULL)) + if (URL_COPYSTR(dst->u_rawurl, src->u_rawurl) || + URL_COPYSTR(dst->u_scheme, src->u_scheme) || + URL_COPYSTR(dst->u_userinfo, src->u_userinfo) || + URL_COPYSTR(dst->u_host, src->u_host) || + URL_COPYSTR(dst->u_hostname, src->u_hostname) || + URL_COPYSTR(dst->u_port, src->u_port) || + URL_COPYSTR(dst->u_rawpath, src->u_rawpath) || + URL_COPYSTR(dst->u_path, src->u_path) || + URL_COPYSTR(dst->u_query, src->u_query) || + URL_COPYSTR(dst->u_fragment, src->u_fragment)) { + nni_url_free(dst); + return (NNG_ENOMEM); + } +#undef URL_COPYSTR + *dstp = dst; + return (0); }
\ No newline at end of file |
