<discocaml>
<score_under> does anyone have any recommendations for an http client library that can do POST requests? i've tried http-lwt-client and piaf, but both simply make invalid requests to the server, and i've tried cohttp-curl-lwt but it has a bug where it pastes one of the request headers into the response text
ralu1 has joined #ocaml
troydm has joined #ocaml
leah2 has joined #ocaml
troydm has quit [Changing host]
troydm has joined #ocaml
Putonlalla has joined #ocaml
pieguy128 has joined #ocaml
riverdc has joined #ocaml
leah2 has quit [Client Quit]
leah2 has joined #ocaml
emp has joined #ocaml
Everything has joined #ocaml
<discocaml>
<score_under> or! I'll just invoke the curl binary. delightfully devilish.
<companion_cube>
You could try ocurl directly
<companion_cube>
(bindings to curl)
<companion_cube>
Or my wrapper around it, ezcurl (make sure to use the latest version)
salkin has joined #ocaml
keyboard has quit [Ping timeout: 260 seconds]
waleee has quit [Ping timeout: 264 seconds]
waleee has joined #ocaml
jakky has joined #ocaml
keyboard has joined #ocaml
salkin has quit [Ping timeout: 264 seconds]
keyboard has quit [Ping timeout: 260 seconds]
Tuplanolla has quit [Quit: Leaving.]
<discocaml>
<anmonteiro> why does piaf make invalid requests?
<discocaml>
<score_under> i honestly do not know
<discocaml>
<anmonteiro> more information would be helpful. that conclusion seems wrong in my experience
<discocaml>
<score_under> i've been testing against my own nginx server and instead of saying "POST / HTTP/1.1" for example, it just says "-" in the section where it's supposed to log the request made. it gives back a 400 error. i've tried with https://httpbin.org/post and had a similar result
<discocaml>
<anmonteiro> ```shell
<discocaml>
<anmonteiro> $ nix run -L github:nix-ocaml/nix-overlays#ocaml-ng.ocamlPackages_5_1.carl -- https://httpbin.org/post -X POST -d hello
<discocaml>
<score_under> this is the last thing I tried in utop to make that requestβ `Piaf.Client.post (Result.get_ok @@ Lwt_main.run @@ Piaf.Client.create @@ Uri.of_string "https://httpbin.org/post") ~headers:["Content-Type","text/plain"] ~body:(Piaf.Body.of_string "testing") "https://httpbin.org/post";;`
<discocaml>
<anmonteiro> oh, you're using some Lwt-based Piaf. that's no longer supported
<discocaml>
<anmonteiro> that also seems wrong. `Lwt_main.run` should only be run once
<discocaml>
<score_under> i assumed it would work in the hacky sense π
<discocaml>
<anmonteiro> not if you never run the `Client.post` promise
<discocaml>
<anmonteiro> (in any case, now that we established you're using Piaf-lwt, don't π )
<discocaml>
<anmonteiro> the repository's master branch has an EIO implementation, which will be the only one supported going forward
<discocaml>
<score_under> fwiw, i get the same result from `Lwt.map (fun client -> Piaf.Client.post (Result.get_ok client) ~headers:["Content-Type","text/plain"] ~body:(Piaf.Body.of_string "testing") "https://httpbin.org/post") (Piaf.Client.create @@ Uri.of_string "https://httpbin.org/post") |> Lwt_main.run;;`
<discocaml>
<score_under> i'm using 0.1.0 which is the latest in opam
<discocaml>
<anmonteiro> can you try posting to `/post`?
<discocaml>
<score_under> I get an OK response from that (`https://httpbin.org/` on create, `/post` on request), maybe it was the URL issue all along with piaf.
<discocaml>
<anmonteiro> sounds like it
<discocaml>
<anmonteiro> (I don't provide support for the lwt-based piaf version, btw)
<discocaml>
<anmonteiro> (I don't provide support for the lwt-based piaf version, btw. meaning you're on your own if you run into bugs)
<discocaml>
<score_under> before this conversation i did not know another version exists (though i am partly playing with this to get used to lwt)
<discocaml>
<anmonteiro> no worries, I'm just setting expectations. I think there's a file descriptor leak in the released version
<discocaml>
<score_under> well, thank you for guiding me through that, apparently piaf and ezcurl are now both on the table as options. out of curiosity what does the cutting-edge piaf use in place of lwt?