Skip to content

Commit

Permalink
Merge pull request #484 from samoht/4.06
Browse files Browse the repository at this point in the history
Use cohttp 1.0 and support OCaml 4.06
  • Loading branch information
samoht authored Jan 3, 2018
2 parents 44049ea + bb03726 commit 855d361
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ env:
matrix:
- OCAML_VERSION=4.03 PACKAGE="irmin-fs.dev" TESTS=true
- OCAML_VERSION=4.04 PACKAGE="irmin-mem.dev" TESTS=true
- OCAML_VERSION=4.03 PACKAGE="irmin-git.dev" TESTS=true
- OCAML_VERSION=4.04 PACKAGE="irmin-http.dev" TESTS=true
- OCAML_VERSION=4.04 PACKAGE="irmin-chunk.dev" TESTS=true
- OCAML_VERSION=4.03 PACKAGE="irmin-mirage.dev"
- OCAML_VERSION=4.04 PACKAGE="irmin-unix.dev" TESTS=true EXTRA_DEPS=inotify
- OCAML_VERSION=4.05 PACKAGE="irmin-git.dev" TESTS=true
- OCAML_VERSION=4.06 PACKAGE="irmin-http.dev" TESTS=true
- OCAML_VERSION=4.06 PACKAGE="irmin-chunk.dev" TESTS=true
- OCAML_VERSION=4.05 PACKAGE="irmin-mirage.dev"
- OCAML_VERSION=4.06 PACKAGE="irmin-unix.dev" TESTS=true EXTRA_DEPS=inotify
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 1.3.3 (2018-01-03)

- complete support for OCaml 4.06 (#484, @samoht)
- support cohttp 1.0 (#484, @samoht)

### 1.3.2 (2017-11-22)

- support OCaml 4.06 where `-safe-string` is enabled by default (#477, @djs55)
Expand Down
2 changes: 1 addition & 1 deletion irmin-git.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"irmin" {>= "1.3.0"}
"git" {>= "1.11.0"}
"alcotest" {test}
"git-unix" {test & >= "1.11.0"}
"git-unix" {test & >= "1.11.4"}
"mtime" {test & >= "1.0.0"}
]

Expand Down
2 changes: 1 addition & 1 deletion irmin-http.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"crunch"
"webmachine" {>= "0.3.2"}
"irmin" {>= "1.3.0"}
"cohttp-lwt" {>= "0.99.0"}
"cohttp-lwt" {>= "1.0.0"}
"irmin-git" {test & >= "1.3.0"}
"irmin-mem" {test & >= "1.3.0"}
"alcotest" {test}
Expand Down
2 changes: 1 addition & 1 deletion irmin-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depends: [
"irmin" {>= "1.3.0"}
"irmin-git" {>= "1.3.0"}
"irmin-mem" {>= "1.3.0"}
"git-mirage" {>= "1.11.0"}
"git-mirage" {>= "1.11.4"}
"ptime"
"mirage-kv-lwt"
"mirage-clock"
Expand Down
2 changes: 1 addition & 1 deletion irmin-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ depends: [
"irmin-git" {>= "1.3.0"}
"irmin-http" {>= "1.3.0"}
"irmin-fs" {>= "1.3.0"}
"git-unix" {>= "1.11.0"}
"git-unix" {>= "1.11.4"}
"irmin-watcher" {>= "0.2.0"}
"alcotest" {test}
"mtime" {test & >= "1.0.0"}
Expand Down
10 changes: 5 additions & 5 deletions src/irmin-http/irmin_http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let json_stream (stream: string Lwt_stream.t): Jsonm.lexeme list Lwt_stream.t =
Lwt_stream.get stream >>= function
| None -> Lwt.fail (Escape (Jsonm.decoded_range d, (`Expected `Value)))
| Some str ->
Jsonm.Manual.src d str 0 (String.length str);
Jsonm.Manual.src d (Bytes.of_string str) 0 (String.length str);
lexeme ()
in
let lexemes e =
Expand Down Expand Up @@ -134,7 +134,7 @@ module Helper (Client: Cohttp_lwt.S.Client) = struct

let map_string_response parse (r, b) =
check_version r >>= fun () ->
Cohttp_lwt_body.to_string b >>= fun b ->
Cohttp_lwt.Body.to_string b >>= fun b ->
if is_success r then
match parse b with
| Ok x -> Lwt.return x
Expand All @@ -146,10 +146,10 @@ module Helper (Client: Cohttp_lwt.S.Client) = struct
let map_stream_response t (r, b) =
check_version r >>= fun () ->
if not (is_success r) then
Cohttp_lwt_body.to_string b >>= fun b ->
Cohttp_lwt.Body.to_string b >>= fun b ->
Lwt.fail_with ("Server error: " ^ b)
else
let stream = Cohttp_lwt_body.to_stream b in
let stream = Cohttp_lwt.Body.to_stream b in
let stream = json_stream stream in
let stream =
let aux j =
Expand Down Expand Up @@ -285,7 +285,7 @@ module RW (Client: Cohttp_lwt.S.Client)
match Cohttp.Response.status r with
| `Not_found | `OK -> Lwt.return_unit
| _ ->
Cohttp_lwt_body.to_string b >>= fun b ->
Cohttp_lwt.Body.to_string b >>= fun b ->
Fmt.kstrf Lwt.fail_with "cannot remove %a: %s" K.pp key b
)

Expand Down
10 changes: 5 additions & 5 deletions src/irmin-http/irmin_http_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module Make (HTTP: Cohttp_lwt.S.Server) (S: Irmin.S) = struct
module P = S.Private

class virtual resource = object
inherit [Cohttp_lwt_body.t] Wm.resource
inherit [Cohttp_lwt.Body.t] Wm.resource
method! finish_request rd =
Wm.Rd.with_resp_headers (fun h ->
Cohttp.Header.add h irmin_version Irmin.version
Expand Down Expand Up @@ -75,7 +75,7 @@ module Make (HTTP: Cohttp_lwt.S.Server) (S: Irmin.S) = struct
method content_types_accepted rd = Wm.continue [] rd

method! process_post rd =
Cohttp_lwt_body.to_string rd.Wm.Rd.req_body >>= fun body ->
Cohttp_lwt.Body.to_string rd.Wm.Rd.req_body >>= fun body ->
match V.of_string body with
| Error e -> parse_error rd body e
| Ok body ->
Expand Down Expand Up @@ -146,7 +146,7 @@ module Make (HTTP: Cohttp_lwt.S.Server) (S: Irmin.S) = struct
inherit resource

method private of_json rd =
Cohttp_lwt_body.to_string rd.Wm.Rd.req_body >>= fun body ->
Cohttp_lwt.Body.to_string rd.Wm.Rd.req_body >>= fun body ->
match of_json (set_t V.t) body with
| Error e -> parse_error rd body e
| Ok v ->
Expand Down Expand Up @@ -222,7 +222,7 @@ module Make (HTTP: Cohttp_lwt.S.Server) (S: Irmin.S) = struct
`Stream stream

method! process_post rd =
Cohttp_lwt_body.to_string rd.Wm.Rd.req_body >>= fun body ->
Cohttp_lwt.Body.to_string rd.Wm.Rd.req_body >>= fun body ->
match of_json T.(list (init_t K.t V.t)) body with
| Error e -> parse_error rd body e
| Ok init ->
Expand Down Expand Up @@ -262,7 +262,7 @@ module Make (HTTP: Cohttp_lwt.S.Server) (S: Irmin.S) = struct
`Stream stream

method! process_post rd =
Cohttp_lwt_body.to_string rd.Wm.Rd.req_body >>= fun body ->
Cohttp_lwt.Body.to_string rd.Wm.Rd.req_body >>= fun body ->
match of_json V.t body with
| Error e -> parse_error rd body e
| Ok init ->
Expand Down
2 changes: 1 addition & 1 deletion src/irmin-unix/bin/ir_resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ let read_config_file (): t option =
let len = in_channel_length oc in
let buf = Bytes.create len in
really_input oc buf 0 len;
let lines = String.cuts ~sep:"\n" buf in
let lines = String.cuts ~sep:"\n" (Bytes.to_string buf) in
let lines = List.map (fun s -> String.trim s) lines in
let lines = List.map (fun s -> String.cut ~sep:"=" s) lines in
let lines =
Expand Down

0 comments on commit 855d361

Please sign in to comment.