httpp/streaming
This module allows you to make an http request to a server and receive a streamed response back which is sent to a process managing it. You can also define a custom message type and send messages and state to this response handler.
Types
This defines the behaviour of the request handler
NOTE: if the on_error handler does not receive a response, the handler will be shut down regardless of if it returns an Ok() result
if the initial response does not arrive within the timeout, the on_error handler will receive the TimedOut
error
pub type StreamingRequestHandler(state, message_type) {
StreamingRequestHandler(
initial_state: state,
req: Request(BytesBuilder),
on_data: fn(Message, Response(Nil), state) ->
Result(state, ExitReason),
on_message: fn(message_type, Response(Nil), state) ->
Result(state, ExitReason),
on_error: fn(hackney.Error, Option(Response(Nil)), state) ->
Result(state, ExitReason),
initial_response_timeout: Int,
)
}
Constructors
-
StreamingRequestHandler( initial_state: state, req: Request(BytesBuilder), on_data: fn(Message, Response(Nil), state) -> Result(state, ExitReason), on_message: fn(message_type, Response(Nil), state) -> Result(state, ExitReason), on_error: fn(hackney.Error, Option(Response(Nil)), state) -> Result(state, ExitReason), initial_response_timeout: Int, )