patch #7303
[mldonkey.git] / src / utils / net / http_server.mli
blob5526d0aa8e77f2b7621c453abe4b251f305f3790
1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
2 (*
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 type auth = No_auth | Read_auth | Write_auth
20 type error_reason = Blocked | Not_allowed | Url_not_found of string
21 and header =
22 Unknown of string * string
23 | Referer of Url.url
24 | Authorization of auth
25 type options = {
26 referer : Url.url option;
27 content_length : int64;
28 content_type : string;
29 login : string;
30 passwd : string;
31 host : string;
32 no_cache : bool;
34 and full_header = string * string
35 and form_arg = {
36 arg_name : string;
37 arg_value : string;
38 arg_args : (string * string) list;
39 arg_headers : full_header list;
41 and version = HTTP1_0 | HTTP1_1 | HTTP
42 and request = {
43 sock : TcpBufferedSocket.t;
44 request : string;
45 version : version;
46 get_url : Url.url;
47 options : options;
48 headers : full_header list;
49 form_args : form_arg list;
51 mutable reply_head : string;
52 mutable reply_headers : (string * string) list;
53 mutable reply_content : string;
54 mutable reply_stream : (TcpBufferedSocket.t -> unit) option;
57 and handler = TcpBufferedSocket.t -> request -> unit
59 and config = {
60 bind_addr : Unix.inet_addr;
61 mutable port : int;
62 requests : (string * handler) list;
63 mutable addrs : Ip_set.blocking_list;
64 use_ip_block_list : bool;
65 base_ref : string;
66 default : handler;
69 val create : config -> TcpServerSocket.t
70 val html_escaped : string -> string
71 val html_real_escaped : string -> string
73 val add_reply_header : request -> string -> string -> unit
74 val handler : config -> 'a -> TcpServerSocket.event -> unit
75 val parse_head : TcpBufferedSocket.t -> string -> request
77 val verbose : bool ref
79 val request_range : request -> int64 * (int64 option)
80 val parse_range : string -> int64 * int64 option * int64 option
81 val error_page : string -> string -> string -> string -> string -> error_reason option -> string * string * string