anchor.diff:      stringify_metadata(Tail, [{binary_to_list(K), binary_to_list(V)}|Acc]);
   stringify_metadata([], Acc) ->
       lists:reverse(Acc).
  +
  +%% ==================================================================
  +%% EUnit test
  +%% ==================================================================
  +-ifdef(TEST).
  +-include_lib("eunit/include/eunit.hrl").
  +
  +encode_body_normal_test_() ->
  +    Msg1 = [{id, <<"id1">>}, {content, {[{<<"content-type">>, <<"text/plain">>}], <<"msg1">>}}],
  +    Msg2 = [{id, <<"id2">>}, {content, {[], <<"msg2">>}}],
  +    Msg3 = [{id, <<"id3">>}, {content, {[{<<"x-lmq-sequence">>, <<"1">>}], <<"msg3">>}}],
  +    [?_assertEqual({[{<<"content-type">>, <<"text/plain">>}], <<"msg1">>},
  +                   encode_body(normal, multipart, Msg1)),
  +     ?_assertEqual({[{<<"content-type">>, <<"application/octet-stream">>}], <<"msg2">>},
  +                   encode_body(normal, multipart, Msg2)),
  +     ?_assertEqual({[{<<"content-type">>, <<"application/octet-stream">>},
  +                     {<<"x-lmq-sequence">>, <<"1">>}], <<"msg3">>},
  +                   encode_body(normal, multipart, Msg3))].
  +
  +encode_body_multipart_test_() ->
  +    Msg1 = [{id, <<"id1">>}, {content, [{[{<<"content-type">>, <<"text/plain">>}], <<"msg1">>},
  +                                        {[], <<"msg2">>},
  +                                        {[{<<"x-lmq-sequence">>, <<"1">>}], <<"msg3">>}]}],
  +    [?_assertEqual([{<<"content-type">>, <<"multipart/mixed; boundary=id1">>}],
  +                   element(1, encode_body(compound, multipart, Msg1))),
  +     ?_assertEqual(<<"\r\n--id1\r\n",
  +                     "content-type: text/plain\r\n",
  +                     "content-transfer-encoding: binary\r\n",
  +                     "\r\n",
  +                     "msg1"
  +                     "\r\n--id1\r\n",
  +                     "content-type: application/octet-stream\r\n",
  +                     "content-transfer-encoding: binary\r\n",
  +                     "\r\n",
  +                     "msg2",
  +                     "\r\n--id1\r\n",
  +                     "content-type: application/octet-stream\r\n",
  +                     "x-lmq-sequence: 1\r\n",
  +                     "content-transfer-encoding: binary\r\n",
  +                     "\r\n",
  +                     "msg3",
  +                     "\r\n--id1--\r\n">>,
  +                   iolist_to_binary(element(2, encode_body(compound, multipart, Msg1))))
  +    ].
  +
  +encode_body_msgpack_test_() ->
  +    Msg1 = [{id, <<"id1">>}, {content, [{[{<<"content-type">>, <<"text/plain">>}], <<"msg1">>},
  +                                        {[], <<"msg2">>},
  +                                        {[{<<"x-lmq-sequence">>, <<"1">>}], <<"msg3">>}]}],
  +    Bin1 = msgpack:pack([[{[{"content-type", "text/plain"}]}, <<"msg1">>],
  +                         [{[{"content-type", "application/octet-stream"}]}, <<"msg2">>],
  +                         [{[{"content-type", "application/octet-stream"},
  +                            {"x-lmq-sequence", "1"}]}, <<"msg3">>]],
  +                        [{enable_str, true}]),
  +    [?_assertEqual({[{<<"content-type">>, <<"application/x-msgpack">>}], Bin1},
  +                   encode_body(compound, msgpack, Msg1))].
  +
  +-endif.
  
positive.code:      <<"\r\n--">>, Boundary, <<"--\r\n">>].
  
  encode_multipart_item({MD, V}) ->
      [<<"Content-Type: ">>,
       proplists:get_value(<<"content-type">>, MD, <<"application/octet-stream">>),
       <<"\r\n">>,
       <<"Content-Transfer-Encoding: binary\r\n">>,
       <<"\r\n">>, V].
  
  stringify_metadata(MD) ->
  
negative.code:     {ok, Req2} = cowboy_req:reply(204, Req),
      {ok, Req2, State};
  info({Ref, Msg}, Req, #state{ref=Ref, cf=CF}=State) ->
      {Hdrs, V} = encode_body(proplists:get_value(type, Msg), CF, Msg),
      Hdrs2 = Hdrs ++ [{<<"x-lmq-queue-name">>,
                        atom_to_binary(proplists:get_value(queue, Msg), latin1)},
                       {<<"x-lmq-message-id">>, proplists:get_value(id, Msg)},
                       {<<"x-lmq-message-type">>,
                        atom_to_binary(proplists:get_value(type, Msg), latin1)}],
      {ok, Req2} = cowboy_req:reply(200, Hdrs2, V, Req),
      {ok, Req2, State};
  info(_Msg, Req, State) ->
      {loop, Req, State}.
  