这是一个用于 Unity 的 C# 封装,可使用已启用 http/2 和 openssl 的 libcurl。
This is a C# wrapper for Unity to use libcurl with http/2 and openssl enabled.
| Name | Version |
|---|---|
| curl | 7.67.0 |
| nghttp2 | 1.39.2 |
| openssl | 1.1.1b |
There are several build script under build folder for each platform:
All the scripts will auto deloy the output files into
Assets/curl-unity/Plugins.
Build libcurl.so for Android. Please use this script on macOS but it should also works on Linux.
Build libcurl.a for iOS. Please use this script on macOS
Build curl.bundle for macOS. Please use this script on macOS.
Build curl.dll for Windows. Please use this script on Windows.
Copy Assets/curl-unity to anywhere under your Unity project and done.
For a better performance you could enable Allow unsafe code and add ALLOW_UNSAFE to the Scripting Define Symbols in the project settings.
A CurlMultiUpdater component is needed to be created before any request and then you could check multiThread on or not.
Only by using this multi perform that could take the advantage of HTTP/2 multiplexing feature.
void Start()
{
for (int i = 0; i Not recommended. You should take care of the thread safe issues and it can't be canceled before done.
```csharp
async void Start()
{
var easy = new CurlEasy();
easy.url = "https://nghttp2.org";
easy.timeout = 5000;
if (await easy.PerformAsync() == CURLE.OK)
{
Debug.Log(easy.inText);
}
}void Start()
{
var easy = new CurlEasy();
easy.url = "https://nghttp2.org";
easy.timeout = 5000;
if (easy.Perform() == CURLE.OK)
{
Debug.Log(easy.inText);
}
}暂无开放 Issues,或尚未同步最近议题。