]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/ocaml-http/http_types.ml
- split http_parser module (all code that parse http requests and
[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 informational_substatus =
30   [ `Continue
31   | `Switching_protocols
32   ]
33
34 type success_substatus =
35   [ `OK
36   | `Created
37   | `Accepted
38   | `Non_authoritative_information
39   | `No_content
40   | `Reset_content
41   | `Partial_content
42   ]
43
44 type redirection_substatus =
45   [ `Multiple_choices
46   | `Moved_permanently
47   | `Found
48   | `See_other
49   | `Not_modified
50   | `Use_proxy
51   | `Temporary_redirect
52   ]
53
54 type client_error_substatus =
55   [ `Bad_request
56   | `Unauthorized
57   | `Payment_required
58   | `Forbidden
59   | `Not_found
60   | `Method_not_allowed
61   | `Not_acceptable
62   | `Proxy_authentication_required
63   | `Request_time_out
64   | `Conflict
65   | `Gone
66   | `Length_required
67   | `Precondition_failed
68   | `Request_entity_too_large
69   | `Request_URI_too_large
70   | `Unsupported_media_type
71   | `Requested_range_not_satisfiable
72   | `Expectation_failed
73   ]
74
75 type server_error_substatus =
76   [ `Internal_server_error
77   | `Not_implemented
78   | `Bad_gateway
79   | `Service_unavailable
80   | `Gateway_time_out
81   | `HTTP_version_not_supported
82   ]
83
84 type informational_status = [ `Informational of informational_substatus ]
85 type success_status = [ `Success of success_substatus ]
86 type redirection_status = [ `Redirection of redirection_substatus ]
87 type client_error_status = [ `Client_error of client_error_substatus ]
88 type server_error_status = [ `Server_error of server_error_substatus ]
89
90 type error_status =
91   [ client_error_status
92   | server_error_status
93   ]
94
95 type status =
96   [ informational_status
97   | success_status
98   | redirection_status
99   | client_error_status
100   | server_error_status
101   ]
102
103 class type response =
104   object
105     method version: version
106     method setVersion: version -> unit
107     method code: int
108     method setCode: int -> unit
109     method status: status
110     method setStatus: status -> unit
111     method reason: string
112     method setReason: string -> unit
113     method statusLine: string
114     method setStatusLine: string -> unit
115     method isInformational: bool
116     method isSuccess: bool
117     method isRedirection: bool
118     method isClientError: bool
119     method isServerError: bool
120     method isError: bool
121     method contents: string
122     method setContents: string -> unit
123     method contentsBuf: Buffer.t
124     method setContentsBuf: Buffer.t -> unit
125     method addContents: string -> unit
126     method addContentsBuf: Buffer.t -> unit
127     method addHeader: name:string -> value:string -> unit
128     method addBasicHeaders: unit
129     method replaceHeader: name:string -> value:string -> unit
130     method removeHeader: name:string -> unit
131     method hasHeader: name:string -> bool
132     method header: name:string -> string
133     method headers: (string * string) list
134     method contentType: string
135     method setContentType: string -> unit
136     method contentEncoding: string
137     method setContentEncoding: string -> unit
138     method date: string
139     method setDate: string -> unit
140     method expires: string
141     method setExpires: string -> unit
142     method server: string
143     method setServer: string -> unit
144     method serialize: out_channel -> unit
145   end
146 class type request =
147   object
148     method uri: string
149     method path: string
150     method param: string -> string
151     method params: (string * string) list
152   end