Skip to content

Commit 59ea6d1

Browse files
committed
Merge branch 'use-fieldslib'
2 parents ddca616 + 1feb4c0 commit 59ea6d1

File tree

13 files changed

+91
-74
lines changed

13 files changed

+91
-74
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.9.12 (trunk):
2+
* Expose Fieldslib setters and getters for most of the `Cohttp` types (#38).
23
* `Cohttp.Set_cookie.t` is no longer an abstract type to make it easier to update (#38).
34
* [Lwt] ignore SIGPIPE unconditionally if using the Lwt/Unix module (#37).
45
* Rename `Cookie` creation parameters for consistency (interface breaking, see #44).

_oasis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Library cohttp
1212
Findlibname: cohttp
1313
Pack: true
1414
Modules: IO, Code, Header, Cookie, Request, Response, Transfer, Accept, Accept_parser, Accept_lexer, Base64, Auth, Header_io, Transfer_io, Client
15-
BuildDepends: re, uri (>= 1.3.8), uri.services
15+
BuildDepends: re, uri (>= 1.3.8), uri.services, fieldslib, fieldslib.syntax
1616

1717
Flag lwt
1818
Description: build the Lwt library

_tags

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: a952834f500b83eea06ca53d69394888)
2+
# DO NOT EDIT (digest: 089787a6c5457a0274e3a8e4ceb59b20)
33
# Ignore VCS directories, you can use the same kind of rule outside
44
# OASIS_START/STOP if you want to exclude directories that contains
55
# useless stuff for the build process
@@ -33,6 +33,8 @@
3333
<cohttp/*.ml{,i}>: pkg_uri
3434
<cohttp/*.ml{,i}>: pkg_re
3535
<cohttp/*.ml{,i}>: pkg_uri.services
36+
<cohttp/*.ml{,i}>: pkg_fieldslib
37+
<cohttp/*.ml{,i}>: pkg_fieldslib.syntax
3638
# Library cohttp_lwt_unix
3739
"lwt/cohttp_lwt_unix.cmxs": use_cohttp_lwt_unix
3840
<lwt/*.ml{,i}>: pkg_lwt.unix
@@ -48,6 +50,8 @@
4850
<lwt/*.ml{,i}>: pkg_mirage-net
4951
<lwt/*.ml{,i}>: pkg_cstruct
5052
<lwt/*.ml{,i}>: pkg_uri.services
53+
<lwt/*.ml{,i}>: pkg_fieldslib
54+
<lwt/*.ml{,i}>: pkg_fieldslib.syntax
5155
# Library cohttp_async
5256
"async/cohttp_async.cmxs": use_cohttp_async
5357
<async/*.ml{,i}>: use_cohttp
@@ -58,6 +62,8 @@
5862
<async/*.ml{,i}>: pkg_async
5963
<async/*.ml{,i}>: pkg_re
6064
<async/*.ml{,i}>: pkg_uri.services
65+
<async/*.ml{,i}>: pkg_fieldslib
66+
<async/*.ml{,i}>: pkg_fieldslib.syntax
6167
# Executable test_parser
6268
<lib_test/test_parser.{native,byte}>: use_cohttp_lwt_unix
6369
<lib_test/test_parser.{native,byte}>: use_cohttp
@@ -69,20 +75,26 @@
6975
<lib_test/test_parser.{native,byte}>: pkg_lwt
7076
<lib_test/test_parser.{native,byte}>: pkg_lwt.ssl
7177
<lib_test/test_parser.{native,byte}>: pkg_uri.services
78+
<lib_test/test_parser.{native,byte}>: pkg_fieldslib
79+
<lib_test/test_parser.{native,byte}>: pkg_fieldslib.syntax
7280
<lib_test/test_parser.{native,byte}>: custom
7381
# Executable test_accept
7482
<lib_test/test_accept.{native,byte}>: use_cohttp
7583
<lib_test/test_accept.{native,byte}>: pkg_oUnit
7684
<lib_test/test_accept.{native,byte}>: pkg_uri
7785
<lib_test/test_accept.{native,byte}>: pkg_re
7886
<lib_test/test_accept.{native,byte}>: pkg_uri.services
87+
<lib_test/test_accept.{native,byte}>: pkg_fieldslib
88+
<lib_test/test_accept.{native,byte}>: pkg_fieldslib.syntax
7989
<lib_test/test_accept.{native,byte}>: custom
8090
# Executable test_header
8191
<lib_test/test_header.{native,byte}>: use_cohttp
8292
<lib_test/test_header.{native,byte}>: pkg_oUnit
8393
<lib_test/test_header.{native,byte}>: pkg_uri
8494
<lib_test/test_header.{native,byte}>: pkg_re
8595
<lib_test/test_header.{native,byte}>: pkg_uri.services
96+
<lib_test/test_header.{native,byte}>: pkg_fieldslib
97+
<lib_test/test_header.{native,byte}>: pkg_fieldslib.syntax
8698
<lib_test/test_header.{native,byte}>: custom
8799
# Executable test_net_lwt
88100
<lib_test/test_net_lwt.{native,byte}>: use_cohttp_lwt_unix
@@ -95,6 +107,8 @@
95107
<lib_test/test_net_lwt.{native,byte}>: pkg_lwt
96108
<lib_test/test_net_lwt.{native,byte}>: pkg_lwt.ssl
97109
<lib_test/test_net_lwt.{native,byte}>: pkg_uri.services
110+
<lib_test/test_net_lwt.{native,byte}>: pkg_fieldslib
111+
<lib_test/test_net_lwt.{native,byte}>: pkg_fieldslib.syntax
98112
<lib_test/test_net_lwt.{native,byte}>: custom
99113
# Executable test_net_lwt_google
100114
<lib_test/test_net_lwt_google.{native,byte}>: use_cohttp_lwt_unix
@@ -106,6 +120,8 @@
106120
<lib_test/test_net_lwt_google.{native,byte}>: pkg_lwt
107121
<lib_test/test_net_lwt_google.{native,byte}>: pkg_lwt.ssl
108122
<lib_test/test_net_lwt_google.{native,byte}>: pkg_uri.services
123+
<lib_test/test_net_lwt_google.{native,byte}>: pkg_fieldslib
124+
<lib_test/test_net_lwt_google.{native,byte}>: pkg_fieldslib.syntax
109125
<lib_test/test_net_lwt_google.{native,byte}>: custom
110126
# Executable test_net_lwt_lastminute
111127
<lib_test/test_net_lwt_lastminute.{native,byte}>: use_cohttp_lwt_unix
@@ -117,6 +133,8 @@
117133
<lib_test/test_net_lwt_lastminute.{native,byte}>: pkg_lwt
118134
<lib_test/test_net_lwt_lastminute.{native,byte}>: pkg_lwt.ssl
119135
<lib_test/test_net_lwt_lastminute.{native,byte}>: pkg_uri.services
136+
<lib_test/test_net_lwt_lastminute.{native,byte}>: pkg_fieldslib
137+
<lib_test/test_net_lwt_lastminute.{native,byte}>: pkg_fieldslib.syntax
120138
<lib_test/test_net_lwt_lastminute.{native,byte}>: custom
121139
# Executable test_net_lwt_server
122140
<lib_test/test_net_lwt_server.{native,byte}>: use_cohttp_lwt_unix
@@ -128,6 +146,8 @@
128146
<lib_test/test_net_lwt_server.{native,byte}>: pkg_lwt
129147
<lib_test/test_net_lwt_server.{native,byte}>: pkg_lwt.ssl
130148
<lib_test/test_net_lwt_server.{native,byte}>: pkg_uri.services
149+
<lib_test/test_net_lwt_server.{native,byte}>: pkg_fieldslib
150+
<lib_test/test_net_lwt_server.{native,byte}>: pkg_fieldslib.syntax
131151
<lib_test/test_net_lwt_server.{native,byte}>: custom
132152
# Executable test_net_lwt_multi_get
133153
<lib_test/test_net_lwt_multi_get.{native,byte}>: use_cohttp_lwt_unix
@@ -139,6 +159,8 @@
139159
<lib_test/test_net_lwt_multi_get.{native,byte}>: pkg_lwt
140160
<lib_test/test_net_lwt_multi_get.{native,byte}>: pkg_lwt.ssl
141161
<lib_test/test_net_lwt_multi_get.{native,byte}>: pkg_uri.services
162+
<lib_test/test_net_lwt_multi_get.{native,byte}>: pkg_fieldslib
163+
<lib_test/test_net_lwt_multi_get.{native,byte}>: pkg_fieldslib.syntax
142164
<lib_test/test_net_lwt_multi_get.{native,byte}>: custom
143165
# Executable test_net_lwt_client_and_server
144166
<lib_test/test_net_lwt_client_and_server.{native,byte}>: use_cohttp_lwt_unix
@@ -150,6 +172,8 @@
150172
<lib_test/test_net_lwt_client_and_server.{native,byte}>: pkg_lwt
151173
<lib_test/test_net_lwt_client_and_server.{native,byte}>: pkg_lwt.ssl
152174
<lib_test/test_net_lwt_client_and_server.{native,byte}>: pkg_uri.services
175+
<lib_test/test_net_lwt_client_and_server.{native,byte}>: pkg_fieldslib
176+
<lib_test/test_net_lwt_client_and_server.{native,byte}>: pkg_fieldslib.syntax
153177
<lib_test/*.ml{,i}>: use_cohttp_lwt_unix
154178
<lib_test/*.ml{,i}>: pkg_lwt.syntax
155179
<lib_test/*.ml{,i}>: pkg_lwt.unix
@@ -167,6 +191,8 @@
167191
<lib_test/test_net_async.{native,byte}>: pkg_async
168192
<lib_test/test_net_async.{native,byte}>: pkg_re
169193
<lib_test/test_net_async.{native,byte}>: pkg_uri.services
194+
<lib_test/test_net_async.{native,byte}>: pkg_fieldslib
195+
<lib_test/test_net_async.{native,byte}>: pkg_fieldslib.syntax
170196
<lib_test/test_net_async.{native,byte}>: custom
171197
# Executable test_net_async_http10
172198
<lib_test/test_net_async_http10.{native,byte}>: use_cohttp_async
@@ -179,6 +205,8 @@
179205
<lib_test/test_net_async_http10.{native,byte}>: pkg_async
180206
<lib_test/test_net_async_http10.{native,byte}>: pkg_re
181207
<lib_test/test_net_async_http10.{native,byte}>: pkg_uri.services
208+
<lib_test/test_net_async_http10.{native,byte}>: pkg_fieldslib
209+
<lib_test/test_net_async_http10.{native,byte}>: pkg_fieldslib.syntax
182210
<lib_test/test_net_async_http10.{native,byte}>: custom
183211
# Executable test_net_async_multi_get
184212
<lib_test/test_net_async_multi_get.{native,byte}>: use_cohttp_async
@@ -191,6 +219,8 @@
191219
<lib_test/test_net_async_multi_get.{native,byte}>: pkg_async
192220
<lib_test/test_net_async_multi_get.{native,byte}>: pkg_re
193221
<lib_test/test_net_async_multi_get.{native,byte}>: pkg_uri.services
222+
<lib_test/test_net_async_multi_get.{native,byte}>: pkg_fieldslib
223+
<lib_test/test_net_async_multi_get.{native,byte}>: pkg_fieldslib.syntax
194224
<lib_test/test_net_async_multi_get.{native,byte}>: custom
195225
# Executable test_net_async_server
196226
<lib_test/test_net_async_server.{native,byte}>: use_cohttp_async
@@ -203,6 +233,8 @@
203233
<lib_test/test_net_async_server.{native,byte}>: pkg_async
204234
<lib_test/test_net_async_server.{native,byte}>: pkg_re
205235
<lib_test/test_net_async_server.{native,byte}>: pkg_uri.services
236+
<lib_test/test_net_async_server.{native,byte}>: pkg_fieldslib
237+
<lib_test/test_net_async_server.{native,byte}>: pkg_fieldslib.syntax
206238
<lib_test/*.ml{,i}>: use_cohttp_async
207239
<lib_test/*.ml{,i}>: use_cohttp
208240
<lib_test/*.ml{,i}>: pkg_oUnit
@@ -213,8 +245,11 @@
213245
<lib_test/*.ml{,i}>: pkg_async
214246
<lib_test/*.ml{,i}>: pkg_re
215247
<lib_test/*.ml{,i}>: pkg_uri.services
248+
<lib_test/*.ml{,i}>: pkg_fieldslib
249+
<lib_test/*.ml{,i}>: pkg_fieldslib.syntax
216250
<lib_test/test_net_async_server.{native,byte}>: custom
217251
# OASIS_STOP
218252
<lib_test/{test_parser,test_net_lwt,test_net_lwt_server,test_net_mirage_server,test_net_lwt_client_and_server}.ml>: syntax_camlp4o, pkg_lwt.syntax
253+
<cohttp/request.*> or <cohttp/response.*> or <cohttp/cookie.*>: syntax_camlp4o, pkg_fieldslib.syntax
219254
<lwt/*>: syntax_camlp4o, pkg_lwt.syntax
220255
true: annot, bin_annot, debug, strict_sequence, principal

cohttp/META

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 7bf24c643dda32c927ea8b69743286c8)
2+
# DO NOT EDIT (digest: 6986af1ee7d3541b9e1fb0656ec3ac2c)
33
version = "0.9.12"
44
description = "HTTP library for Lwt, Async and Mirage"
5-
requires = "re uri uri.services"
5+
requires = "re uri uri.services fieldslib fieldslib.syntax"
66
archive(byte) = "cohttp.cma"
77
archive(byte, plugin) = "cohttp.cma"
88
archive(native) = "cohttp.cmxa"

cohttp/cookie.ml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Set_cookie_hdr = struct
2828
expiration : expiration;
2929
domain : string option;
3030
path : string option;
31-
secure : bool }
31+
secure : bool } with fields
3232

3333
(* Does not check the contents of name or value for ';', ',', '\s', or name[0]='$' *)
3434
let make ?(expiration=`Session) ?path ?domain ?(secure=false) cookie =
@@ -116,11 +116,6 @@ module Set_cookie_hdr = struct
116116
| _ -> (fun _ a -> a)
117117
) hdr []
118118

119-
let cookie { cookie } = cookie
120-
let expiration { expiration } = expiration
121-
let domain { domain } = domain
122-
let path { path } = path
123-
let secure { secure } = secure
124119
let value { cookie=(_,v) } = v
125120
end
126121

cohttp/cookie.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Set_cookie_hdr : sig
2828
expiration : expiration;
2929
domain : string option;
3030
path : string option;
31-
secure : bool }
31+
secure : bool } with fields
3232
(** A header which a server sends to a client to request that the client
3333
returns the cookie in future requests, under certain conditions. *)
3434

cohttp/request.ml

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
*)
1717

1818
type t = {
19-
headers: Header.t;
20-
meth: Code.meth;
21-
uri: Uri.t;
22-
version: Code.version;
23-
encoding: Transfer.encoding;
24-
}
25-
26-
let headers r = r.headers
27-
let meth r = r.meth
28-
let uri r = r.uri
29-
let version r = r.version
30-
let encoding r = r.encoding
19+
mutable headers: Header.t;
20+
mutable meth: Code.meth;
21+
mutable uri: Uri.t;
22+
mutable version: Code.version;
23+
mutable encoding: Transfer.encoding;
24+
} with fields
3125

3226
let make ?(meth=`GET) ?(version=`HTTP_1_1) ?encoding ?headers uri =
3327
let headers =
@@ -58,36 +52,6 @@ let make_for_client ?headers ?(chunked=true) ?(body_length=0) meth uri =
5852
in
5953
make ~meth ~encoding ?headers uri
6054

61-
module type T = sig
62-
val headers : t -> Header.t
63-
val meth : t -> Code.meth
64-
(** Retrieve full HTTP request uri *)
65-
val uri : t -> Uri.t
66-
67-
(** Retrieve HTTP version, usually 1.1 *)
68-
val version : t -> Code.version
69-
70-
(** Retrieve the transfer encoding of this HTTP request *)
71-
val encoding : t -> Transfer.encoding
72-
73-
(** TODO *)
74-
val params : t -> (string * string list) list
75-
76-
(** TODO *)
77-
val get_param : t -> string -> string option
78-
79-
val make : ?meth:Code.meth -> ?version:Code.version ->
80-
?encoding:Transfer.encoding -> ?headers:Header.t ->
81-
Uri.t -> t
82-
83-
val make_for_client:
84-
?headers:Header.t ->
85-
?chunked:bool ->
86-
?body_length:int ->
87-
Code.meth -> Uri.t -> t
88-
end
89-
90-
9155
module type S = sig
9256
module IO : IO.S
9357

cohttp/request.mli

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
the {!headers}, {!version}, {!meth} and {!uri}. The body is handled by
2222
the separate {!S} module type, as it is dependent on the IO
2323
implementation. *)
24-
type t
24+
type t = {
25+
mutable headers: Header.t;
26+
mutable meth: Code.meth;
27+
mutable uri: Uri.t;
28+
mutable version: Code.version;
29+
mutable encoding: Transfer.encoding;
30+
} with fields
2531

2632
(** Retrieve the HTTP request headers *)
2733
val headers : t -> Header.t

cohttp/response.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*
2-
* Copyright (c) 2012 Anil Madhavapeddy <[email protected]>
2+
* Copyright (c) 2012-2013 Anil Madhavapeddy <[email protected]>
33
*
44
* Permission to use, copy, modify, and distribute this software for any
55
* purpose with or without fee is hereby granted, provided that the above
@@ -20,12 +20,7 @@ type t = {
2020
headers: Header.t;
2121
version: Code.version;
2222
status: Code.status_code;
23-
}
24-
25-
let headers r = r.headers
26-
let encoding r = r.encoding
27-
let version r = r.version
28-
let status r = r.status
23+
} with fields
2924

3025
let make ?(version=`HTTP_1_1) ?(status=`OK) ?(encoding=Transfer.Chunked) ?headers () =
3126
let headers = match headers with None -> Header.init () |Some h -> h in

cohttp/response.mli

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
*
1616
*)
1717

18-
type t
18+
type t = {
19+
encoding: Transfer.encoding;
20+
headers: Header.t;
21+
version: Code.version;
22+
status: Code.status_code;
23+
} with fields
1924

2025
(** Retrieve response HTTP headers *)
2126
val headers : t -> Header.t

0 commit comments

Comments
 (0)