module Nethttpd_types:Type definitions for the HTTP daemonsig
..end
Contents
Nethttp
module (part of netstring).
Furthermore, Netcgi_env
and Netcgi_types
are of interest (part of cgi).exception Standard_response of Nethttp.http_status * Nethttp.http_header option * string option
http_status
is sent back to the client.
If the third argument exists, an entry into the error log
is written.typeoutput_state =
[ `End | `Sending | `Start ]
val string_of_output_state : output_state -> string
class type virtual v_extended_environment =object
..end
cgi_environment
for use with the daemon.
class type extended_environment =object
..end
v_extended_environment
, but no virtual methods
class virtual empty_environment :object
..end
class redirected_environment :?in_header:Nethttp.http_header -> ?properties:(string * string) list -> ?in_channel:Netchannels.in_obj_channel -> extended_environment ->
extended_environment
val output_static_response : #extended_environment ->
Nethttp.http_status -> Nethttp.http_header option -> string -> unit
Content-Length
is set to the length of the string.Content-Type
is set to "text/html" unless given by the header.val output_file_response : #extended_environment ->
Nethttp.http_status ->
Nethttp.http_header option -> string -> int64 -> int64 -> unit
Content-Length
is set to the length of the string.Content-Type
is set to "text/html" unless given by the header.Content-Range
is not set automatically, even if the file is only
partially transferred.
If the header is not passed, the header of the environment is taken. If the header argument exists, however, it overrides the header of the environment.
The function raises Sys_error
when the file cannot be read.
class type request_info =object
..end
class type full_info =object
..end
class create_full_info :response_status_code:int -> request_body_rejected:bool -> output_header:Nethttp.http_header -> output_body_size:int64 -> request_info ->
full_info
full_info
object by adding to a request_info
object
class type error_response_params =object
..end
class type min_config =object
..end
output_std_response
val output_std_response : #min_config ->
#extended_environment ->
Nethttp.http_status -> Nethttp.http_header option -> string option -> unit
http_status
. The string argument
is an optional entry into the error log.
If the header is not passed, an empty header is taken. If the header argument
exists, this header is taken. The header of the environment is never taken.
Service providers are defined using the three class types:
http_service
: The service provider as such. When a HTTP header has been
received, and the service provider is invoked, it returns an object
fitting to the next class type, http_service_receiver
. This object
is tagged with `Accept_body
; at this point there are also alternate ways
of processing, see below.http_service_receiver
: The task of this object is to receive the request
body. When the body has been completely received, the object is notified,
and returns a third object of type http_service_generator
.http_service_generator
: The task of this object is to generate the
response.The three objects reflect three stages of HTTP processing. The stages have made explicit to allow the implementor of services to intercept the points in time when the processing of the next stage begins. Furthermore, in multi-threaded environments it is allowed that the stages are performed in the contexts of different threads.
In addition to the three-stage model there also several faster paths of processing:
`Reject_body
can be used to refuse the acceptance of the request body when
it is already clear that an error response is sent back. This path skips
the stage http_service_receiver
.`Static
can be used to send a constant string back (only to be used
when the string needs not to be computed)`File
can be used to send the contents of a file back (only to be used
when the file already exists)exception Redirect_request of string * Nethttp.http_header
exception Redirect_response of string * Nethttp.http_header
GET
.class type http_service_generator =object
..end
class type http_service_receiver =object
..end
typehttp_service_reaction =
[ `Accept_body of http_service_receiver
| `File of
Nethttp.http_status * Nethttp.http_header option * string * int64 * int64
| `Reject_body of http_service_generator
| `Static of Nethttp.http_status * Nethttp.http_header option * string
| `Std_response of
Nethttp.http_status * Nethttp.http_header option * string option ]
`Accept_body
is the regular way of processing requests. If necessary,
the client is told to continue sending the rest of the request.`Reject_body
can be used when the body of the request is not needed,
and the response will be negative.`Static
means to send the header and a constant string back as response.
The header is taken from the environment if not explicitly passed,
Note: The Content-Length
header is automatically added. The Content-Type
defaults to "text/html".`File
is similar to this, but the data come from a file. The file
is specified by an absolute pathname. The range of the file is given
by the start position and the length of the range.
The header is taken from the environment if not explicitly passed,
Note: The Content-Length
header is automatically added. The Content-Type
defaults to "text/html".`Std_response
is similar to `Static
, however the body is the standard
text for the status code. If the header is omitted, it is taken as empty.
The third argument is an optional entry into the error log.
Note: The Content-Length
header is automatically added. The Content-Type
defaults to "text/html".class type['a]
http_service =object
..end
val update_alist : ('a * 'b) list -> ('a * 'b) list -> ('a * 'b) list
update_alist updl l
: Returns the alist with all elements of updl
and all elements of l
that are not member of updl
.