aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-25 22:31:51 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-25 22:32:59 +0200
commitac5c2f40a2e25e12e2cd918e88f2101c5bb2f1fa (patch)
tree425396bfde0b759f3a853dadfa7808abccea9f65
parentbe1e424e172928e39f2d6e8edf681d58b653f862 (diff)
downloadjson-rpc-shell-ac5c2f40a2e25e12e2cd918e88f2101c5bb2f1fa.tar.gz
json-rpc-shell-ac5c2f40a2e25e12e2cd918e88f2101c5bb2f1fa.tar.xz
json-rpc-shell-ac5c2f40a2e25e12e2cd918e88f2101c5bb2f1fa.zip
WS: allow leaving out the URL path
It defaults to / now, it used to cause undefined behaviour.
-rw-r--r--json-rpc-shell.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index c5142f6..f15d5db 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -1307,9 +1307,12 @@ backend_ws_connect (struct app_context *ctx, struct error **e)
struct str url_path;
str_init (&url_path);
- str_append_data (&url_path, self->endpoint +
- self->url.field_data[UF_PATH].off,
- self->url.field_data[UF_PATH].len);
+ if (self->url.field_set & (1 << UF_PATH))
+ str_append_data (&url_path, self->endpoint +
+ self->url.field_data[UF_PATH].off,
+ self->url.field_data[UF_PATH].len);
+ else
+ str_append_c (&url_path, '/');
if (self->url.field_set & (1 << UF_QUERY))
{
str_append_c (&url_path, '?');