data(StreamID, IsFin, Data, State) -> {Commands, State}
StreamID :: cowboy_stream:stream_id()
IsFin :: cowboy_stream:fin()
Data :: binary()
Commands :: cowboy_stream:commands()
State - opaque
cowboy_stream:data - Handle data for a stream
data(StreamID, IsFin, Data, State) -> {Commands, State}
StreamID :: cowboy_stream:stream_id()
IsFin :: cowboy_stream:fin()
Data :: binary()
Commands :: cowboy_stream:commands()
State - opaque
Handle data for a stream.
This function should be called by all stream handlers. It will propagate data to the next configured stream handler. Handlers do not have to propagate data that has been fully handled.
The stream ID.
Whether this is the end of the request body.
The data received.
The commands to be executed.
The state for the next stream handler.
A list of commands and an opaque state is returned.
The list of commands returned should be included in the commands returned from the current stream handler. It can be modified if necessary.
The state should be stored in the current stream handler's state and passed to cowboy_stream when necessary. The state should be treated as opaque.
data(StreamID, IsFin, Data, State=#state{next=Next0}) ->
MyCommands = my_commands(),
{Commands, Next} = cowboy_stream:data(StreamID, IsFin, Data, Next0),
{MyCommands ++ Commands, #state{next=Next}}.
cowboy_stream(3), cowboy_stream:init(3), cowboy_stream:info(3), cowboy_stream:terminate(3), cowboy_stream:early_error(3)
Support my work on Cowboy, Ranch, Gun and Erlang.mk via GitHub Sponsors. The funds cover domain names and development tools.