]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/ocaml-http/http_message.mli
ocaml 3.09 transition
[helm.git] / helm / DEVEL / ocaml-http / http_message.mli
1
2 (*
3   OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
4
5   Copyright (C) <2002-2005> Stefano Zacchiroli <zack@cs.unibo.it>
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU Library General Public License as
9   published by the Free Software Foundation, version 2.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU Library General Public License for more details.
15
16   You should have received a copy of the GNU Library General Public
17   License along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   USA
20 *)
21
22 (** Object Oriented representation of HTTP messages *)
23
24 open Http_types;;
25
26   (** OO representation of an HTTP message
27   @param entity body included in the message
28   @param headers message headers shipped with the message *)
29 class virtual message:
30   body: string -> headers: (string * string) list -> version: version option ->
31   clisockaddr: Unix.sockaddr -> srvsockaddr: Unix.sockaddr ->
32     object
33
34         (** @return message HTTP version, it can be None because older version
35         of the HTTP protocol don't require HTTP version to be told between
36         message source and destination *)
37       method version: version option
38
39         (** set message HTTP version *)
40       method setVersion: version -> unit
41
42         (** @return message body *)
43       method body: string
44
45         (** set message body *)
46       method setBody: string -> unit
47
48         (** @return a Buffer.t connected to message body (Warning: changing this
49         buffer will change message body too) *)
50       method bodyBuf: Buffer.t
51
52         (** set a new Buffer.t used to keep message body *)
53       method setBodyBuf: Buffer.t -> unit
54
55         (** append a string to message body *)
56       method addBody: string -> unit
57
58         (** append a whole buffer to message body *)
59       method addBodyBuf: Buffer.t -> unit
60
61       (** {i header name comparison are performed in a case-insensitive manner
62       as required by RFC2616, actually the implementation works converting all
63       header names in lowercase} *)
64
65         (** add an HTTP header
66         @param name header's name
67         @param value header's value *)
68       method addHeader: name:string -> value:string -> unit
69
70         (** add a list of HTTP headers
71         @param headers a list of pairs: header_name, header_value *)
72       method addHeaders: (string * string) list -> unit
73
74         (** like addHeader but replace previous definition of the same header *)
75       method replaceHeader: name:string -> value:string -> unit
76
77         (** like addHeaders but replace previous definition of headers that were
78         already defined *)
79       method replaceHeaders: (string * string) list -> unit
80
81         (** remove _all_ occurences of an HTTP header from the message
82         @param name name of the header to be removed *)
83       method removeHeader: name:string -> unit
84
85         (** @return true if given header exists in message, false otherwise *)
86       method hasHeader: name:string -> bool
87
88         (** @return value associated to a given header
89         @param name name of the header to lookup
90         @raise Header_not_found if given header wasn't defined in message *)
91       method header: name:string -> string
92
93         (** @return the full set of headers defined for this message, the value
94         returned is an association list from headers name to headers value, an
95         header may occurs more that once in the list *)
96       method headers: (string * string) list
97
98
99         (** @return client Unix.sockaddr *)
100       method clientSockaddr: Unix.sockaddr
101
102         (** @return client address pretty printed *)
103       method clientAddr: string
104
105         (** @return client port *)
106       method clientPort: int
107
108         (** @return server Unix.sockaddr *)
109       method serverSockaddr: Unix.sockaddr
110
111         (** @return server address pretty printed *)
112       method serverAddr: string
113
114         (** @return server port *)
115       method serverPort: int
116
117
118         (** @return for requests first request line, for responses first
119         response line.
120         User by derived requests and responses to implement toString method *)
121       method private virtual fstLineToString: string
122
123         (** @return a string representation of the message *)
124       method toString: string
125
126         (** serialize the message over an output channel *)
127       method serialize: out_channel -> unit
128
129     end
130