Skip to content

Commit f24d169

Browse files
committed
client: do not wrap call args into array
All connection methods do not wrap keys and tuples into arrays - it's responsibility of user to follow IPROTO format. The only exception is method `call` (by mistake, I believe) - it wraps arguments into array and it doesn't allow to pass raw MsgPack to this method since `mpp::as_raw` tag does not work with any other tags. The commit makes method `call` work like other methods - it won't wrap `args` by itself anymore. Closes #108
1 parent bb69791 commit f24d169

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Client/RequestEncoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ RequestEncoder<BUFFER>::encodeCall(const std::string &func, const T &args)
318318
encodeHeader(Iproto::CALL);
319319
mpp::encode(m_Buf, mpp::as_map(std::forward_as_tuple(
320320
MPP_AS_CONST(Iproto::FUNCTION_NAME), func,
321-
MPP_AS_CONST(Iproto::TUPLE), mpp::as_arr(args))));
321+
MPP_AS_CONST(Iproto::TUPLE), args)));
322322
uint32_t request_size = (m_Buf.end() - request_start) - PREHEADER_SIZE;
323323
++request_start;
324324
request_start.set(__builtin_bswap32(request_size));

test/ClientTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ single_conn_call(Connector<BUFFER, NetProvider> &client)
588588
const static char *return_multi = "remote_multi";
589589
const static char *return_nil = "remote_nil";
590590
const static char *return_map = "remote_map";
591+
const static char *echo = "remote_echo";
591592

592593
Connection<Buf_t, NetProvider> conn(client);
593594
int rc = test_connect(client, conn, localhost, port);
@@ -671,6 +672,15 @@ single_conn_call(Connector<BUFFER, NetProvider> &client)
671672
printResponse<BUFFER>(*response,
672673
std::make_tuple(std::make_tuple(std::make_pair("key", int()))));
673674

675+
TEST_CASE("call remote_echo with raw arguments");
676+
/* [1, 2, 3] as a raw MsgPack. */
677+
const char raw_data[4] = {static_cast<char>(0x93), 1, 2, 3};
678+
rid_t f11 = conn.call(echo, mpp::as_raw(raw_data));
679+
client.wait(conn, f11, WAIT_TIMEOUT);
680+
fail_unless(conn.futureIsReady(f11));
681+
response = conn.getResponse(f11);
682+
printResponse<BUFFER>(*response, std::make_tuple(std::make_tuple(0, 0, 0)));
683+
674684
client.close(conn);
675685
}
676686

0 commit comments

Comments
 (0)