Namespace CurlDotNet.Core
Classes
- CurlFtpException
FTP-specific exception.
- CurlHttpException
Exception for HTTP errors (4xx, 5xx status codes).
Thrown by EnsureSuccess() when request fails:
try { result.EnsureSuccess(); } catch (CurlHttpException ex) { Console.WriteLine($"HTTP {ex.StatusCode}: {ex.Message}"); Console.WriteLine($"Response was: {ex.ResponseBody}"); }
- CurlOptions
Represents parsed curl command options.
- CurlRequestBuilder
🎨 Fluent Builder API - Build curl requests programmatically!
For developers who prefer a fluent API over curl command strings. This builder lets you construct HTTP requests using method chaining, perfect for IntelliSense and compile-time checking.
When to use Builder vs Curl String:
- Use Builder - When building requests dynamically, need IntelliSense, or prefer type safety
- Use Curl String - When you have curl commands from docs/examples (paste and go!)
Quick Example:
// Build a request fluently var result = await CurlRequestBuilder .Get("https://api.example.com/users") .WithHeader("Accept", "application/json") .WithHeader("Authorization", "Bearer token123") .WithTimeout(TimeSpan.FromSeconds(30)) .ExecuteAsync(); // Same as: curl -H 'Accept: application/json' -H 'Authorization: Bearer token123' --max-time 30 https://api.example.com/users
- CurlResult
🎯 The response from your curl command - everything you need is here!
After running any curl command, you get this object back. It has the status code, response body, headers, and helpful methods to work with the data.
The API is designed to be intuitive - just type what you want to do:
- Want the body? →
result.Body - Want JSON? →
result.ParseJson<T>()orresult.AsJson<T>() - Want to save? →
result.SaveToFile("path") - Want headers? →
result.Headers["Content-Type"] - Check success? →
result.IsSuccessorresult.EnsureSuccess()
Quick Example:
var result = await Curl.Execute("curl https://api.github.com/users/octocat"); if (result.IsSuccess) // Was it 200-299? { var user = result.ParseJson<User>(); // Parse JSON to your type result.SaveToFile("user.json"); // Save for later }- Want the body? →
- CurlSettings
Fluent builder for .NET-specific curl settings.
- CurlTimings
Detailed timing breakdown of the curl operation.
See where time was spent (like curl -w):
if (result.Timings.Total > 2000) { Console.WriteLine("Slow request! Let's see why:"); Console.WriteLine($"DNS: {result.Timings.NameLookup}ms"); Console.WriteLine($"Connect: {result.Timings.Connect}ms"); Console.WriteLine($"SSL: {result.Timings.AppConnect}ms"); Console.WriteLine($"Wait: {result.Timings.StartTransfer}ms"); }
- ValidationResult
Result of command validation.