Skip to content

Commit

Permalink
io BUGFIX handle prefixed rpc in the rpc reply
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
michalvasko committed Nov 15, 2016
1 parent df296f9 commit 7f0b0ff
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,15 @@ nc_write_msg(struct nc_session *session, int type, ...)
rpc_elem = va_arg(ap, struct lyxml_elem *);
reply = va_arg(ap, struct nc_server_reply *);

nc_write_clb((void *)&arg, "<rpc-reply", 10, 0);
if (rpc_elem && rpc_elem->ns && rpc_elem->ns->prefix) {
nc_write_clb((void *)&arg, "<", 1, 0);
nc_write_clb((void *)&arg, rpc_elem->ns->prefix, strlen(rpc_elem->ns->prefix), 0);
nc_write_clb((void *)&arg, ":rpc-reply", 10, 0);
}
else {
nc_write_clb((void *)&arg, "<rpc-reply", 10, 0);
}

/* can be NULL if replying with a malformed-message error */
if (rpc_elem) {
lyxml_print_clb(nc_write_xmlclb, (void *)&arg, rpc_elem, LYXML_PRINT_ATTRS);
Expand Down Expand Up @@ -1057,7 +1065,14 @@ nc_write_msg(struct nc_session *session, int type, ...)
va_end(ap);
return -1;
}
nc_write_clb((void *)&arg, "</rpc-reply>", 12, 0);
if (rpc_elem && rpc_elem->ns && rpc_elem->ns->prefix) {
nc_write_clb((void *)&arg, "</", 2, 0);
nc_write_clb((void *)&arg, rpc_elem->ns->prefix, strlen(rpc_elem->ns->prefix), 0);
nc_write_clb((void *)&arg, ":rpc-reply>", 11, 0);
}
else {
nc_write_clb((void *)&arg, "</rpc-reply>", 12, 0);
}
break;

case NC_MSG_NOTIF:
Expand Down

0 comments on commit 7f0b0ff

Please sign in to comment.