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
29 type daemon_mode = [ `Single | `Fork | `Thread ]
32 sockaddr:Unix.sockaddr -> timeout:int option ->
33 (in_channel -> out_channel -> unit) ->
36 type informational_substatus =
38 | `Switching_protocols
41 type success_substatus =
45 | `Non_authoritative_information
51 type redirection_substatus =
61 type client_error_substatus =
69 | `Proxy_authentication_required
74 | `Precondition_failed
75 | `Request_entity_too_large
76 | `Request_URI_too_large
77 | `Unsupported_media_type
78 | `Requested_range_not_satisfiable
82 type server_error_substatus =
83 [ `Internal_server_error
86 | `Service_unavailable
88 | `HTTP_version_not_supported
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 ]
103 [ informational_status
106 | client_error_status
107 | server_error_status
110 exception Invalid_header of string
111 exception Invalid_header_name of string
112 exception Invalid_header_value of string
113 exception Invalid_HTTP_version of string
114 exception Invalid_code of int
115 exception Invalid_status of status
117 exception Malformed_query of string
118 exception Malformed_query_part of string * string
119 exception Unsupported_method of string
120 exception Unsupported_HTTP_version of string
121 exception Malformed_request_URI of string
122 exception Malformed_request of string
124 exception Param_not_found of string
126 exception Invalid_status_line of string
127 exception Header_not_found of string
129 class type response =
131 method version: version
132 method setVersion: version -> unit
134 method setCode: int -> unit
135 method status: status
136 method setStatus: status -> unit
137 method reason: string
138 method setReason: string -> unit
139 method statusLine: string
140 method setStatusLine: string -> unit
141 method isInformational: bool
142 method isSuccess: bool
143 method isRedirection: bool
144 method isClientError: bool
145 method isServerError: bool
147 method contents: string
148 method setContents: string -> unit
149 method contentsBuf: Buffer.t
150 method setContentsBuf: Buffer.t -> unit
151 method addContents: string -> unit
152 method addContentsBuf: Buffer.t -> unit
153 method addHeader: name:string -> value:string -> unit
154 method addHeaders: (string * string) list -> unit
155 method addBasicHeaders: unit
156 method replaceHeader: name:string -> value:string -> unit
157 method replaceHeaders: (string * string) list -> unit
158 method removeHeader: name:string -> unit
159 method hasHeader: name:string -> bool
160 method header: name:string -> string
161 method headers: (string * string) list
162 method contentType: string
163 method setContentType: string -> unit
164 method contentEncoding: string
165 method setContentEncoding: string -> unit
167 method setDate: string -> unit
168 method expires: string
169 method setExpires: string -> unit
170 method server: string
171 method setServer: string -> unit
172 method toString: string
173 method serialize: out_channel -> unit
179 method param: string -> string
180 method paramAll: string -> string list
181 method params: (string * string) list
182 method clientSockaddr: Unix.sockaddr
183 method clientAddr: string
184 method clientPort: int
186 class type connection =
188 method getRequest: request option
189 method respond_with: response -> unit
194 method accept: connection
195 method getRequest: request * connection