Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Sep 4, 2024
1 parent cebf3ac commit 80c0362
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion examples/async/async_get.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let main port host () =
Tcp.connect_sock where_to_connect
>>= fun socket ->
let finished = Ivar.create () in
let response_handler = Httpun_examples.Client.print ~on_eof:(Ivar.fill finished) in
let response_handler =
Httpun_examples.Client.print
~on_eof:((Ivar.fill [@ocaml.alert "-deprecated"]) finished) in
let headers = Headers.of_list [ "host", host ] in
Client.create_connection socket >>= fun connection ->
let request_body =
Expand Down
6 changes: 4 additions & 2 deletions examples/async/async_get_pipelined.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ let main port host () =
Tcp.connect_sock where_to_connect
>>= fun socket ->
let finished = Ivar.create () in
let response_handler = Httpun_examples.Client.print ~on_eof:(Ivar.fill finished) in
let response_handler =
Httpun_examples.Client.print
~on_eof:((Ivar.fill [@ocaml.alert "-deprecated"]) finished) in
let request_headers =
Request.create ~headers:(Headers.of_list [ "host", host ]) `GET "/"
in
Expand All @@ -25,7 +27,7 @@ let main port host () =
in
let finished' = Ivar.create () in
let response_handler' =
Httpun_examples.Client.print ~on_eof:(Ivar.fill finished')
Httpun_examples.Client.print ~on_eof:((Ivar.fill [@ocaml.alert "-deprecated"]) finished')
in
let request_body' =
Client.request
Expand Down
2 changes: 1 addition & 1 deletion examples/async/async_https_get.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let response_handler finished response response_body =
let rec on_read bs ~off ~len =
Bigstring.to_string ~pos:off ~len bs |> print_endline;
Body.Reader.schedule_read response_body ~on_read ~on_eof
and on_eof () = Ivar.fill finished () in
and on_eof () = (Ivar.fill [@ocaml.alert "-deprecated"]) finished () in
Body.Reader.schedule_read response_body ~on_read ~on_eof;
| response ->
Format.fprintf Format.std_formatter "%a\n%!" Response.pp_hum response;
Expand Down
6 changes: 4 additions & 2 deletions examples/async/async_post.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let main port host () =
Tcp.connect_sock where_to_connect
>>= fun socket ->
let finished = Ivar.create () in
let response_handler = Httpun_examples.Client.print ~on_eof:(Ivar.fill finished) in
let response_handler =
Httpun_examples.Client.print
~on_eof:((Ivar.fill [@alert "-deprecated"]) finished) in
let headers =
Headers.of_list
[ "transfer-encoding", "chunked"
Expand All @@ -29,7 +31,7 @@ let main port host () =
don't_wait_for (
Reader.read_one_chunk_at_a_time stdin ~handle_chunk:(fun bs ~pos:off ~len ->
Body.Writer.write_bigstring request_body bs ~off ~len;
Body.Writer.flush request_body (fun () -> ());
Body.Writer.flush request_body (fun _reason -> ());
return (`Consumed(len, `Need_unknown)))
>>| function
| `Eof_with_unconsumed_data s -> Body.Writer.write_string request_body s;
Expand Down

0 comments on commit 80c0362

Please sign in to comment.