Nfhttp: A cross platform C++ HTTP library natively interfacing to platforms
github.com
github.com
libcurl is easy to integrate into C++ but hard to get right (this is not curl's fault). I see a lot of bad example code around the web that works(tm) but is not robust. I've seen so much bad curl code that I was moved to write[0] about some of the problems.
libcurl doesn't use OS-level features. It doesn't pick up the users proxy settings or use the cache or cookie store. This is sometimes what you want but for standard client apps Nfhttp's approach is better.
[0] https://sheep.horse/2019/3/using_libcurl_effectively_and_saf...
Then people use Android 4.0 or Windows 2000/XP, and complain they cannot use TLS1.2. And you cannot use the platform defaults, or Android 4.x fails with TLS1.2, because it is not enabled in the defaults, despite being supported. So you enable TLS1.2 and all ciphers, and then Android 8 fails on TLS1.3 due to a trapdoor cipher. Every device trusts different CAs, so you cannot know if https will work, unless you include all the needed certs rather than using the platform certs. Or the platform API is just completely removed like Apache HttpComponents from Android, and you need to rewrite it.
I am surprised about Android though. Is there really no built-in HTTP client in Android that they could use?
I just don't really see the point to how they've gone about this. Cpprestsdk is already structured in a way where writing different native client impls for each platform is part of the design. So, rather than adding more native implementations there, they've put another layer on top of cpprestsdk, and added some new client implementations in this new library, and for others it calls down and uses cpprestsdk's existing implementations.
This seems to fragment things more than if they had simply contributed to (or even forked) Microsoft's project.
The alternative would be some JNI boilerplate to access Android Framework networking APIs.
Seems like this library offers less itself than it says on the tin, given that 3/5 of its native impls just call down to cpprestsdk. It's a pity that spotify didn't simply add CURL and NSURL clients to cppressdk - that would have been far more useful IMO.
C++ REST SDK
curlWindows WinINet, Android JNI for Apache HttpComponents or OkHttp, Linux OpenSSL through another FreePascal library
As for a better alternative, I would suggest Bazel or Buck.
I appreciate the recommendation, though it seems that bazel is heavily focused on java.
Bazel is a multi-language system whose focus is actually on C++. This is because other languages have much simpler compilation models.
I don't see why it would be a downside to have additional language support in your C++ build-system. For example, what happens when you want to do Android?
I've got nothing against additional language support, though having to install java to use it is a bit painful. I'll take a look at it; I appreciate the recommendation.
You originally commented that cmake was awkward and required "gluing together". I'll agree that the syntax is a little alien to those of us with a background in c-like syntax, but it's never seemed that clunky. Any reason why?
So why not hash the remote file to ensure integrity, and make the server an immutable store?
> I've got nothing against additional language support, though having to install java to use it is a bit painful. I'll take a look at it; I appreciate the recommendation.
I would prefer if they did not use Java also. However, you do not need to install a JVM to use Bazel since it ships with one internally. To the end user, Java is just an implementation detail.
> I'll agree that the syntax is a little alien to those of us with a background in c-like syntax, but it's never seemed that clunky.
This was all I was trying to say really :)
Looking at the repo, I think it would be considerable tweaking to take a dependency on Nfhttp when you already depend on some of its dependencies. With Bazel (and similar) you have a clear way to glue things together ("workspaces") so you would just ensure that all dependencies take the same workspace.
CMake ergonomics is death by a 1000 cuts. The syntax is unpleasant and the error messages are very poor.