revery icon indicating copy to clipboard operation
revery copied to clipboard

Fetch API, v2

Open bryphe opened this issue 4 years ago • 7 comments

@lessp has done some awesome work in pioneering a fetch API for us through https://github.com/lessp/fetch

Unfortunately, we can't use it in Onivim 2 yet - I would love to be able to, because we could remove this node-script-shim that we have today: https://github.com/onivim/oni2/blob/63e3159b0f45bed017251e4f35465bcb383a1b50/src/Service/Net/Service_Net.re#L69

There are a couple of blockers:

  1. We need to ensure the fetch strategy works on Windows (and has CI tests for it)
  2. Ideally, the fetch strategy should use libuv as the back-end - I envision Revery / Onivim to use libuv as the event loop. Might be easier once there is a libuv-lwt engine.

bryphe avatar Aug 31 '20 18:08 bryphe

What about using the existing libuv ocaml bindings ? https://github.com/aantron/luv

WhoAteDaCake avatar Nov 07 '20 16:11 WhoAteDaCake

What about using the existing libuv ocaml bindings ? https://github.com/aantron/luv

That's absolutely an alternative, I believe Luv is already used in Oni2. For a viable HTTP(S)-client we'd need to hook it up with something like ocaml-tls. 🙂

lessp avatar Nov 08 '20 10:11 lessp

Definitely - luv + a http/https client built on-top would be perfect

bryphe avatar Nov 09 '20 22:11 bryphe

@bryphe and I discussed using ocurl the other day as a solution to this problem. Pros

  • libcurl is very robust
  • ocurl seems to be a thin wrapper on top of libcurl
  • ocurl contains functions that integrate with Lwt
  • Builds on Windows

Cons

  • As of now, there is no luv integration
  • Might require an esy-libcurl

I'm going to investigate how hard it would be to write an luv wrapper on top of the existing ocurl code. I think it would be fairly similar to the Lwt code 🤞

zbaylin avatar Jan 09 '21 19:01 zbaylin

I made this as a proof of concept: https://github.com/zbaylin/ocurl-luv-test -- the only issues I'm running into as of now is converting a Unix.file_descr to an Luv.Os_fd.Socket.t. Unfortunately, Obj.magic doesn't seem to work and the Unix tools were removed from Luv in order to not depend on Unix. Once I find a fix I think ocurl will definitely be a viable option for this!

zbaylin avatar Jan 13 '21 00:01 zbaylin

Awesome progress @zbaylin !

bryphe avatar Jan 13 '21 01:01 bryphe

Unfortunately, Obj.magic doesn't seem to work and the Unix tools were removed from Luv in order to not depend on Unix

I wonder if we can bring these back in a fork, or just in Revery?

bryphe avatar Jan 13 '21 01:01 bryphe