2 * http://www.ocsigen.org
3 * ocsigen_http_com.ml Copyright (C) 2005
4 * Denis Berthod, Vincent Balat, Jérôme Vouillon
5 * Laboratoire PPS - CNRS Université Paris Diderot
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, with linking exception;
10 * either version 2.1 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 (** Sending and receiving HTTP frames *)
25 Who can raise the exceptions:
31 (** The other side has cleanly closed the connection after a message *)
32 exception Connection_closed
(* R *)
34 (** The connection has been unexpectedly broken *)
35 exception Lost_connection
of exn
(* RrS *)
37 (** No activity on the other side *)
38 exception Timeout
(* RrS *)
39 exception Keepalive_timeout
(* R *)
41 (** Connection killed *)
42 exception Aborted
(* RrS *)
44 type mode
= Answer
| Query
| Nofirstline
46 val create_receiver
: int -> mode
-> Lwt_ssl.socket
-> connection
47 val lock_receiver
: connection
-> unit Lwt.t
48 val unlock_receiver
: connection
-> unit
49 val wakeup_next_request
: connection
-> unit
50 val block_next_request
: connection
-> unit Lwt.t
51 val get_http_frame
: ?head
:bool -> connection
-> Ocsigen_http_frame.t
Lwt.t
52 val connection_id
: connection
-> int
53 val connection_fd
: connection
-> Lwt_ssl.socket
59 val start_processing
: connection
-> (slot
-> unit Lwt.t
) -> unit
60 val wait_all_senders
: connection
-> unit Lwt.t
65 This function may return any I/O error from the channel, or a
66 interrupted stream exception.
69 ?chunked
:bool -> Lwt_chan.out_channel
-> string Ocsigen_stream.t
-> unit Lwt.t
76 ?server_name
:string -> ?headers
:Http_headers.t
->
77 ?proto
:Ocsigen_http_frame.Http_header.proto
-> unit -> sender_type
79 (** Sender with only the server name, and HTTP/1.1 *)
80 val default_sender
: sender_type
84 (** send an HTTP message.
85 [send] may also fail with [Interrupted_stream] exception if the input
86 stream is interrupted.
89 ?reopen
:(unit -> unit Lwt.t
) ->
91 clientproto
:Ocsigen_http_frame.Http_header.proto
->
92 ?mode
:Ocsigen_http_frame.Http_header.http_mode
->
93 ?proto
:Ocsigen_http_frame.Http_header.proto
->
97 Ocsigen_http_frame.result
->
100 val abort
: connection
-> unit
103 (** Use this function to make an action just before sending the result
104 (for example observe the headers that will be sent).
105 The parameter is a function taking the set of headers twice,
106 first as [Ocsigen_http_frame.Http_headers.http_header],
107 second as a [string].
109 val set_result_observer
:
110 (Ocsigen_http_frame.Http_header.http_header
-> string -> unit Lwt.t
) -> unit