Skip to content

Commit 66668ce

Browse files
committed
Cohttp_async now makes the HTTP body type abstract.
Convert code to `Pipe.to_list (Cohttp_async.Body.to_pipe body)` to obtain the list of strings now. Note that this can be optimized to `Cohttp_async.Body.to_string` to remove the subsequent string concatenation, but I chose to minimise code churn for now.
1 parent 81ca2f4 commit 66668ce

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

code/async/search.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let get_definition_from_json json =
2828
let get_definition word =
2929
Cohttp_async.Client.get (query_uri word)
3030
>>= fun (_, body) ->
31-
Pipe.to_list body
31+
Pipe.to_list (Cohttp_async.Body.to_pipe body)
3232
>>| fun strings ->
3333
(word, get_definition_from_json (String.concat strings))
3434

code/async/search_with_error_handling.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let get_definition ~server word =
3030
try_with (fun () ->
3131
Cohttp_async.Client.get (query_uri ~server word)
3232
>>= fun (_, body) ->
33-
Pipe.to_list body
33+
Pipe.to_list (Cohttp_async.Body.to_pipe body)
3434
>>| fun strings ->
3535
(word, get_definition_from_json (String.concat strings)))
3636
>>| function

code/async/search_with_timeout_no_leak.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let get_definition ~server ~interrupt word =
2929
try_with (fun () ->
3030
Cohttp_async.Client.get ~interrupt (query_uri ~server word)
3131
>>= fun (_, body) ->
32-
Pipe.to_list body
32+
Pipe.to_list (Cohttp_async.Body.to_pipe body)
3333
>>| fun strings ->
3434
(word, get_definition_from_json (String.concat strings)))
3535
>>| function

code/async/test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
THIS IS ONLY A TEST.
1+
This is only a test.

0 commit comments

Comments
 (0)