WIP: 'echo' request works end-to-end, yay!
This commit is contained in:
parent
3d05f543df
commit
db7f1476b9
3 changed files with 24 additions and 8 deletions
|
@ -1017,10 +1017,11 @@ http_harvest_headers({ok, Hdr}, Sock, Acc) ->
|
|||
|
||||
protocol_buffers_loop(Sock, S) ->
|
||||
case gen_tcp:recv(Sock, 0) of
|
||||
{ok, _Bin} ->
|
||||
R = #mpb_response{req_id= <<"not paying any attention">>,
|
||||
generic=#mpb_errorresp{code=-6,
|
||||
msg="not implemented"}},
|
||||
{ok, Bin} ->
|
||||
R = do_pb_request(catch machi_pb:decode_mpb_request(Bin)),
|
||||
%% R = #mpb_response{req_id= <<"not paying any attention">>,
|
||||
%% generic=#mpb_errorresp{code=-6,
|
||||
%% msg="not implemented"}},
|
||||
Resp = machi_pb:encode_mpb_response(R),
|
||||
ok = gen_tcp:send(Sock, Resp),
|
||||
protocol_buffers_loop(Sock, S);
|
||||
|
@ -1048,3 +1049,21 @@ split_uri_options(OpsBin) ->
|
|||
[<<"size">>, Bin] ->
|
||||
{size, binary_to_integer(Bin)}
|
||||
end || X <- L].
|
||||
|
||||
do_pb_request(#mpb_request{req_id=ReqID,
|
||||
echo=#mpb_echoreq{message=Msg}}) ->
|
||||
#mpb_response{req_id=ReqID,
|
||||
echo=#mpb_echoresp{message=Msg}};
|
||||
do_pb_request(#mpb_request{req_id=ReqID,
|
||||
auth=#mpb_authreq{}}) ->
|
||||
#mpb_response{req_id=ReqID,
|
||||
generic=#mpb_errorresp{code=1,
|
||||
msg="AUTH not implemented"}};
|
||||
do_pb_request(#mpb_request{req_id=ReqID}) ->
|
||||
#mpb_response{req_id=ReqID,
|
||||
generic=#mpb_errorresp{code=66,
|
||||
msg="Unknown request"}};
|
||||
do_pb_request(_Else) ->
|
||||
#mpb_response{req_id= <<>>,
|
||||
generic=#mpb_errorresp{code=67,
|
||||
msg="Unknown PB request"}}.
|
||||
|
|
|
@ -123,8 +123,6 @@ do_connect_to_pb_listener(P) ->
|
|||
bummer
|
||||
end.
|
||||
|
||||
%% {Reply, S2} = do_send_sync(Cmd, S),
|
||||
|
||||
do_send_sync({echo, String}, #state{sock=Sock}=S) ->
|
||||
try
|
||||
ReqID = <<0>>,
|
||||
|
@ -135,7 +133,6 @@ do_send_sync({echo, String}, #state{sock=Sock}=S) ->
|
|||
{ok, Bin1B} = gen_tcp:recv(Sock, 0),
|
||||
case (catch machi_pb:decode_mpb_response(Bin1B)) of
|
||||
#mpb_response{req_id=ReqID, echo=Echo} = _R1b ->
|
||||
io:format(user, "do_send_sync ~p\n", [_R1b]),
|
||||
{Echo#mpb_echoresp.message, S}
|
||||
end
|
||||
catch X:Y ->
|
||||
|
|
|
@ -50,7 +50,7 @@ smoke_test2() ->
|
|||
{ok, Clnt} = ?C:start_link(Ps),
|
||||
try
|
||||
true = ?C:connected_p(Clnt),
|
||||
String = <<"yo, dawg">>,
|
||||
String = "yo, dawg",
|
||||
String = ?C:echo(Clnt, String),
|
||||
|
||||
ok
|
||||
|
|
Loading…
Reference in a new issue