3 OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
5 Copyright (C) <2002> Stefano Zacchiroli <zack@cs.unibo.it>
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.
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.
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
32 type daemon_mode = [ `Single | `Fork | `Thread ]
35 sockaddr:Unix.sockaddr -> timeout:int option ->
36 (in_channel -> out_channel -> unit) ->
39 type informational_substatus =
41 | `Switching_protocols
44 type success_substatus =
48 | `Non_authoritative_information
54 type redirection_substatus =
64 type client_error_substatus =
72 | `Proxy_authentication_required
77 | `Precondition_failed
78 | `Request_entity_too_large
79 | `Request_URI_too_large
80 | `Unsupported_media_type
81 | `Requested_range_not_satisfiable
85 type server_error_substatus =
86 [ `Internal_server_error
89 | `Service_unavailable
91 | `HTTP_version_not_supported
94 type informational_status = [ `Informational of informational_substatus ]
95 type success_status = [ `Success of success_substatus ]
96 type redirection_status = [ `Redirection of redirection_substatus ]
97 type client_error_status = [ `Client_error of client_error_substatus ]
98 type server_error_status = [ `Server_error of server_error_substatus ]
101 [ client_error_status
102 | server_error_status
106 [ informational_status
109 | client_error_status
110 | server_error_status
113 exception Invalid_header of string
114 exception Invalid_header_name of string
115 exception Invalid_header_value of string
116 exception Invalid_HTTP_version of string
117 exception Invalid_HTTP_method of string
118 exception Invalid_code of int
119 exception Invalid_status of status
121 exception Malformed_query of string
122 exception Malformed_query_part of string * string
123 exception Unsupported_method of string
124 exception Unsupported_HTTP_version of string
125 exception Malformed_request_URI of string
126 exception Malformed_request of string
128 exception Param_not_found of string
130 exception Invalid_status_line of string
131 exception Header_not_found of string
133 class type message = object
135 method version: version
136 method setVersion: version -> unit
139 method setBody: string -> unit
140 method bodyBuf: Buffer.t
141 method setBodyBuf: Buffer.t -> unit
142 method addBody: string -> unit
143 method addBodyBuf: Buffer.t -> unit
145 method addHeader: name:string -> value:string -> unit
146 method addHeaders: (string * string) list -> unit
147 method replaceHeader: name:string -> value:string -> unit
148 method replaceHeaders: (string * string) list -> unit
149 method removeHeader: name:string -> unit
150 method hasHeader: name:string -> bool
151 method header: name:string -> string
152 method headers: (string * string) list
154 method clientSockaddr: Unix.sockaddr
155 method clientAddr: string
156 method clientPort: int
158 method serverSockaddr: Unix.sockaddr
159 method serverAddr: string
160 method serverPort: int
162 method toString: string
163 method serialize: out_channel -> unit
167 class type request = object
174 method param: ?meth:meth -> string -> string
175 method paramAll: ?meth:meth -> string -> string list
176 method params: (string * string) list
177 method params_GET: (string * string) list
178 method params_POST: (string * string) list
182 class type response = object
187 method setCode: int -> unit
188 method status: status
189 method setStatus: status -> unit
190 method reason: string
191 method setReason: string -> unit
192 method statusLine: string
193 method setStatusLine: string -> unit
195 method isInformational: bool
196 method isSuccess: bool
197 method isRedirection: bool
198 method isClientError: bool
199 method isServerError: bool
202 method addBasicHeaders: unit
203 method contentType: string
204 method setContentType: string -> unit
205 method contentEncoding: string
206 method setContentEncoding: string -> unit
208 method setDate: string -> unit
209 method expires: string
210 method setExpires: string -> unit
211 method server: string
212 method setServer: string -> unit
216 class type connection =
218 method getRequest: request option
219 method respond_with: response -> unit
225 method accept: connection
226 method getRequest: request * connection