Skip to content

Commit

Permalink
Lib: amqp_parse_url should initialize output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alanxz committed Oct 25, 2015
1 parent 110ae32 commit 937c10b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions librabbitmq/amqp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions librabbitmq/amqp_url.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion tests/test_parse_url.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 937c10b

Please sign in to comment.