# Module Nethttpd_reactor

    module Nethttpd_reactor: sig .. end

# The reactive encapsulation of the HTTP daemon

This is a user-friendlier encapsulation of the HTTP daemon. It uses a "pull model": One pulls HTTP requests from the "reactor" one after the other. Request/response pairs have a common environment that represents the input and output facilities. Input and output are realised by `Netchannels`, and the implementation details are completely hidden.

This encapsulation can be easily used in a multi-threaded environment when for every arriving HTTP connection a separate thread is used.

    class type http_processor_config = object .. end

    val default_http_processor_config : http_processor_config

Default configuration: Extends `Nethttpd_kernel.default_http_protocol_config` with

- `config_timeout_next_request = 15.0`
- `config_timeout = 300.0`
- `config_cgi =` `Netcgi.default_config`
- `config_error_response =` `Nethttpd_util.std_error_response`
- `config_log_error`: Uses `Nethttpd_util.std_error_log_string` to write a log message via `Netlog`.
- `config_log_access`: is a no-op

    class modify_http_processor_config : ?modify_http_protocol_config:Nethttpd_kernel.http_protocol_config -> Nethttpd_kernel.http_protocol_config -> ?config_timeout_next_request:float -> ?config_timeout:float -> ?config_cgi:Netcgi.config -> ?config_error_response:Nethttpd_types.error_response_params -> string -> ?config_log_error:Nethttpd_types.request_info -> string -> unit -> ?config_log_access:Nethttpd_types.full_info -> unit -> http_processor_config -> http_processor_config

Modifies the passed config object as specified by the optional arguments.

    class type http_reactor_config = object .. end

    val default_http_reactor_config : http_reactor_config

Default configuration: Extends `Nethttpd_reactor.default_http_processor_config` with

- `config_reactor_synch = `Write`

    class modify_http_reactor_config : ?modify_http_protocol_config:Nethttpd_kernel.http_protocol_config -> Nethttpd_kernel.http_protocol_config -> ?modify_http_processor_config:http_processor_config ->
           http_processor_config -> ?config_reactor_synch:[ `Close | `Connection | `Flush | `Write ] -> http_reactor_config -> http_reactor_config

Modifies the passed config object as specified by the optional arguments.

    class type internal_environment = object .. end

For private use only

    class http_environment : #http_processor_config -> string -> string -> Nethttp.protocol -> Nethttp.http_header -> Unix.sockaddr -> Unix.sockaddr -> Netchannels.in_obj_channel -> int64 Pervasives.ref -> Netchannels.out_obj_channel -> Nethttpd_types.output_state Pervasives.ref -> Nethttpd_kernel.http_response -> (unit -> unit) -> bool Pervasives.ref -> int64 -> internal_environment

For private use only

    class type http_reactive_request = object .. end

    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.

    val process_connection : #http_reactor_config ->
           Unix.file_descr -> 'a Nethttpd_types.http_service -> unit

Processes all HTTP requests in turn arriving at the file descriptor, and calls the service provider for every request. Finally, the descriptor is closed.

All stages of HTTP processing, as defined by the service provider, are executed in the current thread.

Any exceptions are caught and logged. The connection is immediately closed in this case.

# Debugging

    module Debug: sig .. end