summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2015-10-24 21:43:31 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2015-10-24 22:00:14 -0700
commit937c10bbe64a36579bc8bafcd29554e786143c86 (patch)
tree9628d9d6f0c06bd3c112818818fff261aed18923
parent110ae32047f2c5fc18d2326d8307d42e08790b82 (diff)
downloadrabbitmq-c-937c10bbe64a36579bc8bafcd29554e786143c86.tar.gz
Lib: amqp_parse_url should initialize output
amqp_parse_url() calls amqp_default_connection_info() to initialize the output parameter to sensible defaults that mirror what the Java and .NET do. Fixes #319
-rw-r--r--librabbitmq/amqp.h4
-rw-r--r--librabbitmq/amqp_url.c2
-rw-r--r--tests/test_parse_url.c1
3 files changed, 6 insertions, 1 deletions
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h
index ed5f35a..c699a83 100644
--- a/librabbitmq/amqp.h
+++ b/librabbitmq/amqp.h
@@ -2306,6 +2306,10 @@ AMQP_CALL amqp_default_connection_info(struct amqp_connection_info *parsed);
* amqp://guest:guest\@localhost:5672//
* amqp://guest:guest\@localhost/myvhost
*
+ * Any missing parts of the URL will be set to the defaults specified in
+ * amqp_default_connection_info. For amqps: URLs the default port will be set
+ * to 5671 instead of 5672 for non-SSL URLs.
+ *
* \note This function modifies url parameter.
*
* \param [in] url URI to parse, note that this parameter is modified by the
diff --git a/librabbitmq/amqp_url.c b/librabbitmq/amqp_url.c
index 33024cf..636a9de 100644
--- a/librabbitmq/amqp_url.c
+++ b/librabbitmq/amqp_url.c
@@ -120,6 +120,8 @@ int amqp_parse_url(char *url, struct amqp_connection_info *parsed)
char *host;
char *port = NULL;
+ amqp_default_connection_info(parsed);
+
/* check the prefix */
if (!strncmp(url, "amqp://", 7)) {
/* do nothing */
diff --git a/tests/test_parse_url.c b/tests/test_parse_url.c
index b54ace2..533a910 100644
--- a/tests/test_parse_url.c
+++ b/tests/test_parse_url.c
@@ -78,7 +78,6 @@ static void parse_success(const char *url,
struct amqp_connection_info ci;
int res;
- amqp_default_connection_info(&ci);
res = amqp_parse_url(s, &ci);
if (res) {
fprintf(stderr,