Appmod skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
out(Arg) -> | |
case Arg#arg.clidata of | |
undefined -> | |
%% No body | |
do_something_without_clidata(Arg); | |
{partial, Bin} when Arg#arg.state == undefined -> | |
%% chunked request: first chunk received | |
{get_more, Arg#arg.cont, [Bin]}; | |
{partial, Bin} -> | |
%% chunked request: accumulate data and request the next chunk | |
{get_more, Arg#arg.cont, [Bin|Arg#arg.state]}; | |
Bin when Arg#arg.state /= undefined -> | |
%% chunked request: final chunk | |
Data = iolist_to_binary(lists:reverse([Bin|Arg#arg.state])), | |
do_something_with_clidata(Arg#arg{clidata=Data, state=undefined}); | |
Bin -> | |
%% non-chunked request: all data received | |
do_something_with_clidata(Arg) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment