jgaa / RESTinCurl

Modern C++ header only library wrapper around libcurl
MIT License
28 stars 8 forks source link

Are there plans still to port this to Windows? Or is this project dead? #2

Open Tiparium opened 1 year ago

Tiparium commented 1 year ago

Title says all, I'd really like to use this for a project I'm working on on Windows. I tried to use the restc-cpp library, but I couldn't figure out how to get it up and running. I appreciate the simplicity of this version.

jgaa commented 1 year ago

Interesting question ;)

The project is not dead - it's just doing everything it has been designed to do without any issues (known to me).

Nobody has asked for a windows version, until now. I know libcurl works with windows, and the posix async code should work with windows as well. So I guess I'll take a look in the next days and see if I can get it running reliable under windows within a reasonable effort.

Tiparium commented 1 year ago

Gotcha, I thought I'd ask given it looks like last update was four years ago. I found a workaround for my personal project that uses the JUCE frameworks's HTTP system (I'm already using JUCE for all my user interface work), but it would still be really cool to have a lightweight Rest API library that doesn't require JUCE in order to run. Out of curiosity, does this work on Android?

jgaa commented 1 year ago

This is a small open source project, made to solve a specific problem. There are no investors to scam, no team of developers to keep busy. Things only change when changes are warranted ;)

This project was written to handle REST requests in Android and IOS libraries, without requiring other big libraries like boost or asio, or bloating the limited resources on cheap Android phones with enormous C++ templates (apparently simple things can generate surprisingly huge code segments when C++ templates are instantiated).

pierre-aimi commented 1 year ago

Hi @jgaa, sorry for dredging up this thread. I've been looking at trying to get the aysnc code working under Windows lately, and I'm pretty stuck. There doesn't seem to be any clear mapping between the pipe()/select() code operating on file descriptors and the Windows api. Have you had a chance to look at this? Do you have any pointers?

jgaa commented 1 year ago

I think it uses the posix layer under windows.

Here is an example for libcurl that I think will compile and run under Windows.

I don't have Windows installed on any physical machines any more. Microsoft is just too annoying. Whenever I log in to the virtual machine I use for build automaton, I just get really pissed off by their AI "assistant", all the games, and promotions for payed Micorsoft apps in the start menu, and all the dark patterns they apply to make me use the Edge web browser. It's at the point where I regard using windows a health hazard to me (high blood pressure, very high stress levels).

I will eventually look into this, but I have to do it when I have a calm period with low stress and lot's of energy.

pierre-aimi commented 1 year ago

I'm pretty sure that example won't compile under Windows, #include <unistd.h> is unix* specific. Or do you mean the Windows Subsystem for Linux?

Currently I'm able to compile under Windows, just not with Async switched on. In the async code, what doesn't work is mostly an anonymous, non-blocking pipe() call and a select() (which only works on sockets in windows unfortunately) so the solution looks a bit more complicated.

BTW I'm a long time Linux user, not a fan of Windows (it stresses me too, lol) and use Proton for all my games but we're porting our app at work (currently Linux+OSX) to Windows and are wondering:

I'm here to help if that's possible

jgaa commented 1 year ago

Let me take a closer look over the weekend. It would be nice to make the library work under Windows. And I don't want to lose the async functionality.

jgaa commented 1 year ago

I spent some time this weekend looking at a windows port. It's been a while since I wrote the code, so it will take some more time to get it right.

pierre-aimi commented 1 year ago

OK no problem, let me know how you go.

scharli commented 1 year ago

Hi, do you have any update on this matter? Thanks or your effort.

pierre-aimi commented 1 year ago

We've had to go back to using Async for our solution, so also still interested in this.

jgaa commented 1 year ago

I'll try to make it work for windows this week.

scharli commented 1 year ago

Great, thanks for the effort @jgaa !

jgaa commented 1 year ago

I have refactored the async code and made a few other changes to make MSVC compile the code. The changes are in branch https://github.com/jgaa/RESTinCurl/tree/new-async

It works "on my machine" as we used to say. I'm a bit reluctant to merge the changes to master until I have an idea if it works on other peoples machines as well ;)

pierre-aimi commented 1 year ago

Amazing. I'll test and get back to you!

scharli commented 1 year ago

Thank, so much. I will test asap.

pierre-aimi commented 8 months ago

Sorry for the very late reply, I got pulled off this and only finally have returned to test it properly.

So currently I'm able to swap this in and compile, but neither async or sync work for me, I'm getting a 415 error: "None of these media types are available: Application/json"

I'm calling this: client.Build() ->Post(url) .AcceptJson() .WithJson(payload.dump()) .Header("Authorization", "Bearer " + JWT) .Header("content-type", "application/json") .Header("user-agent", "xxxxxx") .Header("Prefer", "return=representation") .Header("Accept-Encoding", "gzip, deflate") .Option(CURLOPT_ACCEPT_ENCODING, "gzip, deflate") .Option(CURLOPT_FOLLOWLOCATION, 1L) .Option(CURLOPT_SSL_VERIFYPEER, 0L) .RequestTimeout(request_timeout) .ConnectTimeout(connect_timeout) .WithCompletion(...etc)

Any suggestions?

jgaa commented 8 months ago

Is is possible to capture the request with wireshark? That will give the complete picture of what's going on. It's simpler if you can use the API with plain http. If https is the only option, it's a bit more work as the payload must be decrypted.

pierre-aimi commented 8 months ago

Sorry was sick lately. I'm happy to capture stuff using Wireshark, but I think https may be the only option. How should I get this data to you? Post it here?

jgaa commented 7 months ago

I havent tested this, but I think libcurl has support to dump the tls keys.

https://daniel.haxx.se/blog/2018/01/15/inspect-curls-tls-traffic/