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_HTTP_version of string
112 exception Invalid_code of int
113 exception Invalid_status of Http_types.status
115 exception Malformed_query of string
116 exception Malformed_query_part of string * string
117 exception Unsupported_method of string
118 exception Unsupported_HTTP_version of string
119 exception Malformed_request_URI of string
120 exception Malformed_request of string
122 exception Param_not_found of string
124 exception Invalid_status_line of string
125 exception Header_not_found of string
127 class type response =
129 method version: version
130 method setVersion: version -> unit
132 method setCode: int -> unit
133 method status: status
134 method setStatus: status -> unit
135 method reason: string
136 method setReason: string -> unit
137 method statusLine: string
138 method setStatusLine: string -> unit
139 method isInformational: bool
140 method isSuccess: bool
141 method isRedirection: bool
142 method isClientError: bool
143 method isServerError: bool
145 method contents: string
146 method setContents: string -> unit
147 method contentsBuf: Buffer.t
148 method setContentsBuf: Buffer.t -> unit
149 method addContents: string -> unit
150 method addContentsBuf: Buffer.t -> unit
151 method addHeader: name:string -> value:string -> unit
152 method addBasicHeaders: unit
153 method replaceHeader: name:string -> value:string -> unit
154 method removeHeader: name:string -> unit
155 method hasHeader: name:string -> bool
156 method header: name:string -> string
157 method headers: (string * string) list
158 method contentType: string
159 method setContentType: string -> unit
160 method contentEncoding: string
161 method setContentEncoding: string -> unit
163 method setDate: string -> unit
164 method expires: string
165 method setExpires: string -> unit
166 method server: string
167 method setServer: string -> unit
168 method toString: string
169 method serialize: out_channel -> unit
175 method param: string -> string
176 method paramAll: string -> string list
177 method params: (string * string) list