Open bwindels opened 6 years ago
it would be good if read_body
or handle_event
could not return ReadBody
. So maybe read_headers
returns:
enum HeadersResult {
ReadBody(something that implements `BodyReader` or so)
Respond(Option<Reponse>) //None means wait for more events
}
and read_body
(and handle_event
) keeps Result<Option<Response>>
as a return type.
If any of these methods return None as response, and there are no async sources registered apart from the connection socket, return 500
.
Requires #21
investigate if we can somehow have a handler for each individual async source?
Right now if the http handler
read_headers
method returnsNone
, a 500 is returned fromhandle_no_response
. Reading the body into a buffer (or file?) and callingread_body
on the handler needs to be implemented still.read_headers
should return whether the body should be read into a buffer or afile::Writer
. This also ties into http handlers being able to wait on other async sources (like an http client) before responding. Soread_headers
would return either of:Ok(Response)
Ok(ReadBody(File(size) | Buffer(size)))
Ok(WaitingForOtherAsyncSources)
Err
read_body
would return:Ok(Response)
Ok(WaitingForOtherAsyncSources)
Err
a third method (
handle_event
) on the http handler would also be needed to handle non-connection-socket events, that would return the same asread_body
:Ok(Response)
Ok(WaitingForOtherAsyncSources)
Err
One danger is that a bug could cause the response to never be returned if all 2 or 3 methods return WaitingForOtherAsyncSources