]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/ocaml-http/http_types.ml
- added method 'param_all' to request objects
[helm.git] / helm / DEVEL / ocaml-http / http_types.ml
1
2 (*
3   OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
4
5   Copyright (C) <2002> 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 General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11
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 General Public License for more details.
16
17   You should have received a copy of the GNU 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
20 *)
21
22 type version =
23   [ `HTTP_1_0
24   | `HTTP_1_1
25   ]
26
27 type meth = [ `GET ]
28
29 type daemon_mode = [ `Single | `Fork | `Thread ]
30
31 type tcp_server =
32   sockaddr:Unix.sockaddr -> timeout:int option ->
33   (in_channel -> out_channel -> unit) ->
34     unit
35
36 type informational_substatus =
37   [ `Continue
38   | `Switching_protocols
39   ]
40
41 type success_substatus =
42   [ `OK
43   | `Created
44   | `Accepted
45   | `Non_authoritative_information
46   | `No_content
47   | `Reset_content
48   | `Partial_content
49   ]
50
51 type redirection_substatus =
52   [ `Multiple_choices
53   | `Moved_permanently
54   | `Found
55   | `See_other
56   | `Not_modified
57   | `Use_proxy
58   | `Temporary_redirect
59   ]
60
61 type client_error_substatus =
62   [ `Bad_request
63   | `Unauthorized
64   | `Payment_required
65   | `Forbidden
66   | `Not_found
67   | `Method_not_allowed
68   | `Not_acceptable
69   | `Proxy_authentication_required
70   | `Request_time_out
71   | `Conflict
72   | `Gone
73   | `Length_required
74   | `Precondition_failed
75   | `Request_entity_too_large
76   | `Request_URI_too_large
77   | `Unsupported_media_type
78   | `Requested_range_not_satisfiable
79   | `Expectation_failed
80   ]
81
82 type server_error_substatus =
83   [ `Internal_server_error
84   | `Not_implemented
85   | `Bad_gateway
86   | `Service_unavailable
87   | `Gateway_time_out
88   | `HTTP_version_not_supported
89   ]
90
91 type informational_status = [ `Informational of informational_substatus ]
92 type success_status = [ `Success of success_substatus ]
93 type redirection_status = [ `Redirection of redirection_substatus ]
94 type client_error_status = [ `Client_error of client_error_substatus ]
95 type server_error_status = [ `Server_error of server_error_substatus ]
96
97 type error_status =
98   [ client_error_status
99   | server_error_status
100   ]
101
102 type status =
103   [ informational_status
104   | success_status
105   | redirection_status
106   | client_error_status
107   | server_error_status
108   ]
109
110 class type response =
111   object
112     method version: version
113     method setVersion: version -> unit
114     method code: int
115     method setCode: int -> unit
116     method status: status
117     method setStatus: status -> unit
118     method reason: string
119     method setReason: string -> unit
120     method statusLine: string
121     method setStatusLine: string -> unit
122     method isInformational: bool
123     method isSuccess: bool
124     method isRedirection: bool
125     method isClientError: bool
126     method isServerError: bool
127     method isError: bool
128     method contents: string
129     method setContents: string -> unit
130     method contentsBuf: Buffer.t
131     method setContentsBuf: Buffer.t -> unit
132     method addContents: string -> unit
133     method addContentsBuf: Buffer.t -> unit
134     method addHeader: name:string -> value:string -> unit
135     method addBasicHeaders: unit
136     method replaceHeader: name:string -> value:string -> unit
137     method removeHeader: name:string -> unit
138     method hasHeader: name:string -> bool
139     method header: name:string -> string
140     method headers: (string * string) list
141     method contentType: string
142     method setContentType: string -> unit
143     method contentEncoding: string
144     method setContentEncoding: string -> unit
145     method date: string
146     method setDate: string -> unit
147     method expires: string
148     method setExpires: string -> unit
149     method server: string
150     method setServer: string -> unit
151     method toString: string
152     method serialize: out_channel -> unit
153   end
154 class type request =
155   object
156     method uri: string
157     method path: string
158     method param: string -> string
159     method param_all: string -> string list
160     method params: (string * string) list
161   end