companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
pieguy128_ has quit [*.net *.split]
leah2 has quit [*.net *.split]
troydm has quit [*.net *.split]
emp has quit [*.net *.split]
riverdc has quit [*.net *.split]
ralu1 has quit [*.net *.split]
Putonlalla has quit [*.net *.split]
Everything has quit [*.net *.split]
<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> <anmonteiro> {
<discocaml> <anmonteiro> "args": {},
<discocaml> <anmonteiro> "data": "hello",
<discocaml> <anmonteiro> "files": {},
<discocaml> <anmonteiro> "form": {},
<discocaml> <anmonteiro> "headers": {
<discocaml> <anmonteiro> "Content-Length": "5",
<discocaml> <anmonteiro> "Host": "httpbin.org",
<discocaml> <anmonteiro> "User-Agent": "carl/0.0.0-experimental",
<discocaml> <anmonteiro> "X-Amzn-Trace-Id": "Root=1-64a0c79e-5538e0fd697be14f254593da"
<discocaml> <anmonteiro> },
<discocaml> <anmonteiro> "json": null,
<discocaml> <anmonteiro> "origin": "107.3.165.86",
<discocaml> <anmonteiro> "url": "https://httpbin.org/post"
<discocaml> <anmonteiro> }
<discocaml> <anmonteiro>
<discocaml> <anmonteiro> ```
<discocaml> <anmonteiro> seems like Piaf can request that server
<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> <anmonteiro> {
<discocaml> <anmonteiro> "args": {},
<discocaml> <anmonteiro> "data": "hello",
<discocaml> <anmonteiro> "files": {},
<discocaml> <anmonteiro> "form": {},
<discocaml> <anmonteiro> "headers": {
<discocaml> <anmonteiro> "Content-Length": "5",
<discocaml> <anmonteiro> "Host": "httpbin.org",
<discocaml> <anmonteiro> "User-Agent": "carl/0.0.0-experimental",
<discocaml> <anmonteiro> "X-Amzn-Trace-Id": "Root=1-64a0c79e-5538e0fd697be14f254593da"
<discocaml> <anmonteiro> },
<discocaml> <anmonteiro> "json": null,
<discocaml> <anmonteiro> "origin": "MY_IP :)",
<discocaml> <anmonteiro> "url": "https://httpbin.org/post"
<discocaml> <anmonteiro> }
<discocaml> <anmonteiro>
<discocaml> <anmonteiro> ```
<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> <anmonteiro> instead of `https://httpbin.org/post/https://httpbin.org/post`
<discocaml> <anmonteiro> `Client.create` should be the origin URL and the `post` call should be the target path
<discocaml> <score_under> is that what it means! the docs suggested that it was an initial endpoint and.... something πŸ˜›
<discocaml> <anmonteiro> it's a bit confusing, and there's an open issue about it
<discocaml> <anmonteiro> uhhh, closed <https://github.com/anmonteiro/piaf/issues/16>
<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?
<discocaml> <anmonteiro> it uses EIO
gwizon has joined #ocaml
<discocaml> <anurag_soni> @score_under if you are ever interested in `async`, I maintain a library that implements http 1.1 servers and clients for it: <https://github.com/anuragsoni/shuttle_http#getting-started-with-clients>
azimut has quit [Ping timeout: 240 seconds]
spip has quit [Quit: Konversation terminated!]
azimut has joined #ocaml
waleee has quit [Ping timeout: 264 seconds]
chrisz has quit [Ping timeout: 260 seconds]
tizoc has quit [Quit: Coyote finally caught me]
chrisz has joined #ocaml
tizoc has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
bartholin has joined #ocaml
patrick is now known as Guest8168
Guest8168 has quit [Killed (cadmium.libera.chat (Nickname regained by services))]
patrick__ has joined #ocaml
reynir[m] has quit [Server closed connection]
reynir[m] has joined #ocaml
Techcable has joined #ocaml
Serpent7776 has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
infinity0 has quit [Ping timeout: 245 seconds]
gareppa has joined #ocaml
infinity0 has joined #ocaml
keyboard has joined #ocaml
keyboard has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
Tuplanolla has joined #ocaml
mongol has joined #ocaml
mongol has quit [Remote host closed the connection]
mongol has joined #ocaml
mongol has quit [Remote host closed the connection]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
landonf has quit [Ping timeout: 260 seconds]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
landonf has joined #ocaml
infinity0 has joined #ocaml
pgiarrusso has quit [Server closed connection]
pgiarrusso has joined #ocaml
Serpent7776 has quit [Ping timeout: 246 seconds]
buoy49_ has quit [Server closed connection]
buoy49_ has joined #ocaml
infinity0 has quit [Remote host closed the connection]
alexherbo2 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
Serpent7776 has joined #ocaml
spip has joined #ocaml
azimut has joined #ocaml
bgs has joined #ocaml
Serpent7776 has quit [Ping timeout: 250 seconds]
Serpent7776 has joined #ocaml
gwizon has quit [Quit: Lost terminal]
TrillionEuroNote has quit [Ping timeout: 246 seconds]
TrillionEuroNote has joined #ocaml
patrick__ is now known as patrick
waleee has joined #ocaml
gareppa has quit [Quit: WeeChat 3.8]
bartholin has quit [Quit: Leaving]
bgs has quit [Remote host closed the connection]
Serpent7776 has quit [Ping timeout: 264 seconds]