Revery: Fetch API, v2

Created on 31 Aug 2020  路  7Comments  路  Source: revery-ui/revery

@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.

All 7 comments

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

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. 馃檪

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

@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 馃

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!

Awesome progress @zbaylin !

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bryphe picture bryphe  路  3Comments

bryphe picture bryphe  路  5Comments

jericdeleon picture jericdeleon  路  3Comments

bryphe picture bryphe  路  6Comments

nic0lino picture nic0lino  路  6Comments