CurlCommands 1.0.1
.NET 10.0
This package targets .NET 10.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package CurlCommands --version 1.0.1
NuGet\Install-Package CurlCommands -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CurlCommands" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CurlCommands" Version="1.0.1" />
<PackageReference Include="CurlCommands" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CurlCommands --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CurlCommands, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CurlCommands@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CurlCommands&version=1.0.1
#tool nuget:?package=CurlCommands&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CurlCommands
Parse and execute curl command strings at runtime via HttpClient. Zero external dependencies.
Install
dotnet add package CurlCommands
Usage
using CurlCommands;
using var httpClient = new HttpClient();
// Simple GET
var response = await httpClient.ExecuteCurlAsync("https://api.example.com/users");
// POST with JSON body
var response = await httpClient.ExecuteCurlAsync(
"curl -X POST https://api.example.com/users " +
"-H 'Content-Type: application/json' " +
"-d '{\"name\":\"John\",\"email\":\"john@example.com\"}'");
// --json flag (auto Content-Type + Accept)
var response = await httpClient.ExecuteCurlAsync(
"curl --json '{\"name\":\"John\"}' https://api.example.com/users");
// Save response to file
var response = await httpClient.ExecuteCurlAsync(
"curl -o result.json https://api.example.com/users");
// Pre-parse and reuse
CurlCommand cmd = CurlCommand.Parse("curl -X POST https://api.example.com/users -d '{}'");
var response = await httpClient.ExecuteCurlAsync(cmd);
// Fire-and-forget (executes request, disposes response)
await httpClient.ExecuteCurlAndForgetAsync(
"-X POST https://api.example.com/webhook -d '{\"event\":\"deploy\"}'");
The curl prefix is optional.
Supported Options
| Option | Description |
|---|---|
-X, --request |
HTTP method (GET, POST, PUT, DELETE, etc.) |
-H, --header |
Request header (Name: Value) |
-d, --data, --data-raw |
Request body (implies POST) |
--data-binary |
Binary request body |
--json |
JSON request body (auto Content-Type + Accept) |
-F, --form |
Multipart form field (name=value or file=@path) |
-o, --output |
Save response body to file |
-u, --user |
Basic auth credentials (user:password) |
--oauth2-bearer |
Bearer token authentication |
-b, --cookie |
Cookie header |
-A, --user-agent |
User-Agent header |
-e, --referer |
Referer header |
-L, --location |
Follow redirects |
-k, --insecure |
Skip SSL certificate validation |
--compressed |
Accept gzip/deflate encoding |
--connect-timeout |
Connection timeout in seconds |
--max-time |
Maximum request time in seconds |
--data-urlencode |
URL-encode data (name=value, implies POST) |
-x, --proxy |
Use HTTP proxy |
-G, --get |
Force GET; data becomes query string |
-I, --head |
HEAD request |
-T, --upload-file |
Upload file via PUT |
--cert, --cert-type |
Client certificate (PEM, DER, P12) |
--key, --key-type |
Client certificate private key |
-U, --proxy-user |
Proxy credentials (user:password) |
--http1.0, --http1.1, --http2, --http3 |
HTTP version |
Features
- Shell-accurate tokenizer -- handles single quotes, double quotes, backslash escaping, and line continuations
- Implicit method detection --
-dimplies POST,-Fimplies POST - Combined short flags --
-sLkexpands to silent + location + insecure - Content-Type routing -- Content-Type headers are correctly placed on
HttpContent, not on the request - JSON flag --
--jsonauto-sets Content-Type and Accept toapplication/json - Output to file --
-o/--outputsaves response body to disk - Basic and Bearer auth --
-u user:passand--oauth2-bearer token - Multipart form data --
-F 'file=@/path/to/file;type=application/pdf' - Timeout support --
--max-timeand--connect-timeoutviaCancellationToken - Insecure mode --
-kuses an internalHttpClientthat skips certificate validation - URL encoding --
--data-urlencodeautomatically encodes values - Proxy support --
-x/--proxyroutes requests through an HTTP proxy - Force GET --
-Gmoves-ddata to query string parameters - File upload --
-Tuploads files via PUT - Client certificates --
--cert/--keyfor mutual TLS - Proxy auth --
-U/--proxy-userfor proxy credentials - HTTP version --
--http1.0through--http3 - Pre-parsed commands --
CurlCommand.Parse()for reuse and inspection
Error Handling
Parse errors throw CurlParseException with a descriptive message. HTTP errors follow standard HttpClient behavior -- use response.EnsureSuccessStatusCode() or check response.IsSuccessStatusCode.
using CurlCommands.Exceptions;
try
{
var response = await httpClient.ExecuteCurlAsync("-X GET"); // no URL
}
catch (CurlParseException ex)
{
Console.WriteLine(ex.Message); // "No URL found in curl command."
}
Target Frameworks
netstandard2.0-- .NET Framework 4.6.1+, .NET Core 2.0+net10.0-- modern .NET
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.