{"id":14990011,"url":"https://github.com/stil/curlthin","last_synced_at":"2025-04-12T02:01:47.441Z","repository":{"id":143436599,"uuid":"91520722","full_name":"stil/CurlThin","owner":"stil","description":"Lightweight cURL wrapper for C# with support for curl_multi polling interface through libuv","archived":false,"fork":false,"pushed_at":"2023-11-23T15:17:04.000Z","size":143,"stargazers_count":69,"open_issues_count":13,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-11T02:06:10.402Z","etag":null,"topics":["curl","http","http-client","libcurl","libuv","multiprocessing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-05-17T01:33:06.000Z","updated_at":"2025-02-27T14:33:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"a9bd65f7-a58c-4112-a534-7a1f05245e3b","html_url":"https://github.com/stil/CurlThin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stil%2FCurlThin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stil%2FCurlThin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stil%2FCurlThin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stil%2FCurlThin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stil","download_url":"https://codeload.github.com/stil/CurlThin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505862,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","http","http-client","libcurl","libuv","multiprocessing"],"created_at":"2024-09-24T14:19:19.659Z","updated_at":"2025-04-12T02:01:47.416Z","avatar_url":"https://github.com/stil.png","language":"C#","readme":"# CurlThin #\n[![Gitter](https://img.shields.io/gitter/room/CurlThin/Lobby.svg)](https://gitter.im/CurlThin/Lobby)\n\n\n_CurlThin_ is a NET Standard compatible binding library against [libcurl](http://curl.haxx.se/libcurl).\nIt includes a modern wrapper for `curl_multi` interface which uses polling with [libuv](https://libuv.org/) library instead of using inefficient `select`.\n\n_CurlThin_ has a very thin abstraction layer, which means that writing the code is as close as possible to writing purely in libcurl. libcurl has extensive documentation and relatively strong support of community and not having additional abstraction layer makes it easier to search solutions for your problems.\n\nUsing this library is very much like working with cURL's raw C API.\n\n### License ###\nLibrary is MIT licensed. NuGet icon made by [Freepik](http://www.freepik.com) and is licensed by [CC 3.0 BY](https://creativecommons.org/licenses/by/3.0/)\n\n## Installation ##\n\n| Package   | NuGet        | MyGet | Description  |\n|-----------|--------------|-------|--------------|\n| `CurlThin` | [![Nuget](https://img.shields.io/nuget/v/CurlThin.svg)](https://www.nuget.org/packages/CurlThin/) | ![MyGet](https://img.shields.io/myget/curlthin/vpre/CurlThin.svg) | The C# wrapper for libcurl.  |\n| `CurlThin.Native` | [![Nuget](https://img.shields.io/nuget/v/CurlThin.Native.svg)](https://www.nuget.org/packages/CurlThin.Native/) | ![MyGet](https://img.shields.io/myget/curlthin/vpre/CurlThin.Native.svg) | Contains embedded libcurl native binaries for x86 and x64 Windows. |\n\nIf you have `libcurl` or `libcurl.dll` already in your PATH directory, you don't need to install `CurlThin.Native` package. Once you have installed `CurlThin.Native` NuGet package, call following method just once before you use cURL:\n\n```csharp\nCurlResources.Init();\n```\n\nIt will extract following files to your application output directory\n\n| Windows x86 | Windows x64 | Description |\n|-------------|-------------|-------------|\n| libcurl.dll | libcurl.dll | The multiprotocol file transfer library. |\n| libssl-1_1.dll | libssl-1_1-x64.dll | Portion of OpenSSL which supports TLS ( SSL and TLS Protocols), and depends on libcrypto. |\n| libcrypto-1_1.dll | libcrypto-1_1-x64.dll | Provides the fundamental cryptographic routines used by libssl. |\n| curl-ca-bundle.crt | curl-ca-bundle.crt | Certificate Authority (CA) bundle. You can use it via [`CURLOPT_CAINFO`](https://curl.haxx.se/libcurl/c/CURLOPT_CAINFO.html). |\n\n## Examples ##\n\n### Easy interface ###\n\n#### GET request ####\n```csharp\n// curl_global_init() with default flags.\nvar global = CurlNative.Init();\n\n// curl_easy_init() to create easy handle.\nvar easy = CurlNative.Easy.Init();\ntry\n{\n    CurlNative.Easy.SetOpt(easy, CURLoption.URL, \"http://httpbin.org/ip\");\n\n    var stream = new MemoryStream();\n    CurlNative.Easy.SetOpt(easy, CURLoption.WRITEFUNCTION, (data, size, nmemb, user) =\u003e\n    {\n        var length = (int) size * (int) nmemb;\n        var buffer = new byte[length];\n        Marshal.Copy(data, buffer, 0, length);\n        stream.Write(buffer, 0, length);\n        return (UIntPtr) length;\n    });\n\n    var result = CurlNative.Easy.Perform(easy);\n\n    Console.WriteLine($\"Result code: {result}.\");\n    Console.WriteLine();\n    Console.WriteLine(\"Response body:\");\n    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));\n}\nfinally\n{\n    easy.Dispose();\n\n    if (global == CURLcode.OK)\n    {\n        CurlNative.Cleanup();\n    }\n}\n```\n\n\n#### POST request ####\n```csharp\n// curl_global_init() with default flags.\nvar global = CurlNative.Init();\n\n// curl_easy_init() to create easy handle.\nvar easy = CurlNative.Easy.Init();\ntry\n{\n    var postData = \"fieldname1=fieldvalue1\u0026fieldname2=fieldvalue2\";\n\n    CurlNative.Easy.SetOpt(easy, CURLoption.URL, \"http://httpbin.org/post\");\n\n    // This one has to be called before setting COPYPOSTFIELDS.\n    CurlNative.Easy.SetOpt(easy, CURLoption.POSTFIELDSIZE, Encoding.ASCII.GetByteCount(postData));\n    CurlNative.Easy.SetOpt(easy, CURLoption.COPYPOSTFIELDS, postData);\n    \n    var stream = new MemoryStream();\n    CurlNative.Easy.SetOpt(easy, CURLoption.WRITEFUNCTION, (data, size, nmemb, user) =\u003e\n    {\n        var length = (int) size * (int) nmemb;\n        var buffer = new byte[length];\n        Marshal.Copy(data, buffer, 0, length);\n        stream.Write(buffer, 0, length);\n        return (UIntPtr) length;\n    });\n\n    var result = CurlNative.Easy.Perform(easy);\n\n    Console.WriteLine($\"Result code: {result}.\");\n    Console.WriteLine();\n    Console.WriteLine(\"Response body:\");\n    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));\n}\nfinally\n{\n    easy.Dispose();\n\n    if (global == CURLcode.OK)\n    {\n        CurlNative.Cleanup();\n    }\n}\n```\n\n### Multi interface ###\n\n#### Web scrape StackOverflow questions ####\nSee [Multi/HyperSample.cs](CurlThin.Samples/Multi/HyperSample.cs).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstil%2Fcurlthin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstil%2Fcurlthin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstil%2Fcurlthin/lists"}