svg_converted: fix build (zlib2 split)
[mldonkey.git] / src / utils / net / http_client.mli
bloba8edfb69c8f32f7015cddb1852349f999fd587bc
1 (* Copyright 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
20 type http_request =
21 GET
22 | POST
23 | HEAD
24 | PUT
25 | DELETE
26 | TRACE
29 | OPTIONS of url option (* None = '*' *)
30 | CONNECT of string * int
32 val verbose : bool ref
34 type request = {
35 req_headers : ( string * string ) list;
36 req_user_agent : string;
37 req_accept : string;
38 req_proxy : (string * int * (string * string) option) option; (** (host,port,(login,password)) *)
39 mutable req_url : Url.url;
40 mutable req_gzip : bool;
41 mutable req_save_to_file_time : float;
42 (* re-download a saved file only if newer *)
43 req_request : http_request;
44 req_referer : Url.url option;
45 req_retry : int;
46 req_max_retry : int;
47 req_save : bool;
48 (** maximum time whole request processing is allowed to take, in seconds *)
49 req_max_total_time : float;
50 (** this function is called after DNS resolution,
51 returning [false] will block connection to the given ip
52 and HTTP request will fail with `Block error *)
53 req_filter_ip : (Ip.t -> bool);
56 type content_handler =
57 int64 -> (string * string) list -> TcpBufferedSocket.t -> int -> unit
59 val basic_request : request
61 (** either HTTP error code or low-level network error or DNS *)
62 type error = [ `HTTP of int | `RST of BasicSocket.close_reason | `DNS | `Block of Ip.t ]
63 val show_error : error -> string
65 val get_page : request -> content_handler -> (unit -> unit) -> (error -> unit) -> unit
66 val wget : request -> (string -> unit) -> unit
67 val whead : request -> ( (string * string) list -> unit) -> unit
68 val whead2 : request -> ( (string * string) list -> unit) -> (error -> unit) -> unit
70 val wget_string : request -> (string -> unit) -> ?ferr:(error -> unit) ->
71 (int -> int64 -> unit) -> unit
73 val split_header : string -> string list
74 val cut_headers : string list -> (string * (string * string)) list