bwindels / wwwee

wwwee, the wee webserver: a small, robust, low-resource and fast web application server for low workloads (home server, personal cloud)
GNU General Public License v3.0
26 stars 1 forks source link

Support reading request body #9

Open bwindels opened 6 years ago

bwindels commented 6 years ago

Right now if the http handler read_headers method returns None, a 500 is returned from handle_no_response. Reading the body into a buffer (or file?) and calling read_body on the handler needs to be implemented still. read_headers should return whether the body should be read into a buffer or a file::Writer. This also ties into http handlers being able to wait on other async sources (like an http client) before responding. So read_headers would return either of:

read_body would return:

a third method (handle_event) on the http handler would also be needed to handle non-connection-socket events, that would return the same as read_body:

One danger is that a bug could cause the response to never be returned if all 2 or 3 methods return WaitingForOtherAsyncSources

bwindels commented 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.

bwindels commented 6 years ago

Requires #21

bwindels commented 5 years ago

investigate if we can somehow have a handler for each individual async source?