module Http_types: sig
.. end
Type definitions
type
version = [ `HTTP_1_0 | `HTTP_1_1 ]
HTTP version, actually only 1.0 and 1.1 are supported. Note that
'supported' here means only 'accepted inside a HTTP request line', no
different behaviours are actually implemented depending on HTTP version
type
meth = [ `GET | `POST ]
HTTP method, actually only GET and POST methods are supported
type
daemon_mode = [ `Fork | `Single | `Thread ]
Daemon behaviour wrt request handling. `Single mode use a single process
to handle all requests, no request is served until a previous one has been
fully served. `Fork mode fork a new process for each request, the new process
will execute the callback function and then exit. `Thread mode create a new
thread for each request, the new thread will execute the callback function and
then exit, threads can communicate using standard OCaml Thread library.
type
tcp_server = sockaddr:Unix.sockaddr ->
timeout:int option ->
(Pervasives.in_channel -> Pervasives.out_channel -> unit) -> unit
A TCP server is a function taking an address on which bind and listen for
connections, an optional timeout after which abort client connections and a
callback function which in turn takes an input and an output channel as
arguments. After receiving this argument a TCP server sits and waits for
connection, on each connection it apply the callback function to channels
connected to client.
type
auth_info = [ `Basic of string * string ]
authentication information
type
informational_substatus = [ `Continue | `Switching_protocols ]
See also RFC2616 informational HTTP status
type
success_substatus = [ `Accepted
| `Created
| `No_content
| `Non_authoritative_information
| `OK
| `Partial_content
| `Reset_content ]
See also RFC2616 success HTTP status
type
redirection_substatus = [ `Found
| `Moved_permanently
| `Multiple_choices
| `Not_modified
| `See_other
| `Temporary_redirect
| `Use_proxy ]
See also RFC2616 redirection HTTP status
type
client_error_substatus = [ `Bad_request
| `Conflict
| `Expectation_failed
| `Forbidden
| `Gone
| `Length_required
| `Method_not_allowed
| `Not_acceptable
| `Not_found
| `Payment_required
| `Precondition_failed
| `Proxy_authentication_required
| `Request_URI_too_large
| `Request_entity_too_large
| `Request_time_out
| `Requested_range_not_satisfiable
| `Unauthorized
| `Unsupported_media_type ]
See also RFC2616 client error HTTP status
type
server_error_substatus = [ `Bad_gateway
| `Gateway_time_out
| `HTTP_version_not_supported
| `Internal_server_error
| `Not_implemented
| `Service_unavailable ]
See also RFC2616 server error HTTP status
type
informational_status = [ `Informational of informational_substatus ]
type
success_status = [ `Success of success_substatus ]
type
redirection_status = [ `Redirection of redirection_substatus ]
type
client_error_status = [ `Client_error of client_error_substatus ]
type
server_error_status = [ `Server_error of server_error_substatus ]
type
error_status = [ `Client_error of client_error_substatus
| `Server_error of server_error_substatus ]
type
status = [ `Client_error of client_error_substatus
| `Informational of informational_substatus
| `Redirection of redirection_substatus
| `Server_error of server_error_substatus
| `Success of success_substatus ]
HTTP status
type
status_code = [ `Code of int | `Status of status ]
type
file_source =
| |
FileSrc of string |
| |
InChanSrc of Pervasives.in_channel |
File sources
Exceptions
exception Invalid_header of string
invalid header encountered
exception Invalid_header_name of string
invalid header name encountered
exception Invalid_header_value of string
invalid header value encountered
exception Invalid_HTTP_version of string
unsupported or invalid HTTP version encountered
exception Invalid_HTTP_method of string
unsupported or invalid HTTP method encountered
exception Invalid_code of int
invalid HTTP status code integer representation encountered
exception Malformed_URL of string
invalid URL encountered
exception Malformed_query of string
invalid query string encountered
exception Malformed_query_part of string * string
invalid query string part encountered, arguments are parameter name and
parameter value
exception Malformed_request_URI of string
invalid request URI encountered
exception Malformed_request of string
malformed request received
exception Malformed_response of string
malformed response received, argument is response's first line
exception Param_not_found of string
a parameter you were looking for was not found
exception Invalid_status_line of string
invalid HTTP status line encountered
exception Header_not_found of string
an header you were looking for was not found
exception Quit
raisable by callbacks to make main daemon quit, this is the only
'clean' way to make start functions return
exception Unauthorized of string
raisable by callbacks to force a 401 (unauthorized) HTTP answer.
This exception should be raised _before_ sending any data over given out
channel.
OO representation of HTTP messages
class type message = object
.. end
HTTP generic messages.
class type request = object
.. end
HTTP requests
class type response = object
.. end
HTTP responses
Daemon specification
type
daemon_spec = {
|
address : string ; |
|
auth : (string * auth_info) option ; |
|
callback : request -> Pervasives.out_channel -> unit ; |
|
mode : daemon_mode ; |
|
port : int ; |
|
root_dir : string option ; |
|
exn_handler : (exn -> Pervasives.out_channel -> unit) option ; |
|
timeout : int option ; |
|
auto_close : bool ; |
}
daemon specification, describe the behaviour of an HTTP daemon.
The default daemon specification is Http_daemon.default_spec
OO representation of other HTTP entities
class type connection = object
.. end
an HTTP connection from a client to a server
class type daemon = object
.. end
an HTTP daemon