Plasma GitLab Archive
Projects Blog Knowledge

Class Nethttpd_reactor.http_reactor


class http_reactor : #http_reactor_config -> Unix.file_descr -> object .. end
The http_reactor allows one to pull the next request from a connected client, and to deliver the response to the protocol engine.

method next_request : unit -> http_reactive_request option
Tries to read the next request. When the header of the request is successfully read, the method returns the request object (see above). It is connected with the socket and can read the request body.

After receiving the request, one must either call accept_body when the request is acceptable and one want to reply afer evaluating the body, or invoke reject_body when the request can be denied without looking at the body. One must also call accept_body when there is not any body (it is a no-op then). The HTTP protocol explicitly forbids to perform the request when reject_body has been invoked ("The origin server MUST NOT perform the requested method if it returns a final status code").

The response must be written to the Netcgi environment. Depending on config_reactor_synch the response is immediately transmitted to the client or at some specified time in the future (untransmitted data is buffered in this case).

While transmitting output, the reactor is able to read the next request in the background when the limits for the pipeline size allows that.

While receiving input, the reactor is able to write untransmitted response data in the background.

It is an error to call next_request again before the previous request is completely processed (you can ensure this by calling finish). In this case the HTTP connection is immediately shut down.

The method next_request returns None when all requests of the connection are processed.

method close : unit -> unit
Closes the file descriptor with a reliable method. This method must be called after next_request returned None. It can also be called at any time to shut down the connection prematurely (this means a lingering close, and may cost some time).
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml