Table of Contents

Class CurlSettings

Namespace
CurlDotNet.Core
Assembly
CurlDotNet.dll

Fluent builder for .NET-specific curl settings.

public class CurlSettings
Inheritance
CurlSettings
Inherited Members

Examples

var settings = new CurlSettings()
    .WithTimeout(30)
    .WithRetries(3)
    .WithProgress((percent, total, current) => Console.WriteLine($"{percent}%"))
    .WithCancellation(cancellationToken);

var result = await Curl.Execute("curl https://example.com", settings);

Remarks

These settings complement curl commands with .NET-specific features.

AI-Usage: Use this for cancellation, progress, retries, and other .NET features.

Properties

AutomaticDecompression

Whether to automatically decompress response.

public bool AutomaticDecompression { get; set; }

Property Value

bool

BufferSize

Buffer size for download operations.

public int BufferSize { get; set; }

Property Value

int

CancellationToken

Cancellation token for the operation.

public CancellationToken CancellationToken { get; set; }

Property Value

CancellationToken

ConnectTimeoutSeconds

Connection timeout in seconds.

public int? ConnectTimeoutSeconds { get; set; }

Property Value

int?

Cookies

Cookie container for maintaining session.

public CookieContainer Cookies { get; set; }

Property Value

CookieContainer

FollowRedirects

Whether to follow redirects.

public bool? FollowRedirects { get; set; }

Property Value

bool?

Headers

Additional headers to add to the request.

public Dictionary<string, string> Headers { get; set; }

Property Value

Dictionary<string, string>

Insecure

Whether to ignore SSL certificate errors.

public bool? Insecure { get; set; }

Property Value

bool?

MaxTimeSeconds

Maximum time in seconds for the entire operation.

public int? MaxTimeSeconds { get; set; }

Property Value

int?

OnProgress

Progress callback (percent, totalBytes, currentBytes).

public Action<double, long, long> OnProgress { get; set; }

Property Value

Action<double, long, long>

OnRedirect

Callback for each redirect.

public Action<string> OnRedirect { get; set; }

Property Value

Action<string>

Proxy

Proxy settings.

public IWebProxy Proxy { get; set; }

Property Value

IWebProxy

RetryCount

Number of retry attempts on failure.

public int RetryCount { get; set; }

Property Value

int

RetryDelayMs

Delay between retries in milliseconds.

public int RetryDelayMs { get; set; }

Property Value

int

UserAgent

Custom user agent string.

public string UserAgent { get; set; }

Property Value

string

Methods

FromDefaults()

Create default settings from global Curl settings.

public static CurlSettings FromDefaults()

Returns

CurlSettings

WithAutoDecompression(bool)

Set automatic decompression.

public CurlSettings WithAutoDecompression(bool enable = true)

Parameters

enable bool

Returns

CurlSettings

WithBufferSize(int)

Set buffer size for downloads.

public CurlSettings WithBufferSize(int size)

Parameters

size int

Returns

CurlSettings

WithCancellation(CancellationToken)

Set cancellation token.

public CurlSettings WithCancellation(CancellationToken token)

Parameters

token CancellationToken

Returns

CurlSettings

WithConnectTimeout(int)

Set connection timeout.

public CurlSettings WithConnectTimeout(int seconds)

Parameters

seconds int

Returns

CurlSettings

WithCookies(CookieContainer)

Use cookie container for session management.

public CurlSettings WithCookies(CookieContainer container = null)

Parameters

container CookieContainer

Returns

CurlSettings

WithFollowRedirects(bool)

Enable or disable following redirects.

public CurlSettings WithFollowRedirects(bool follow = true)

Parameters

follow bool

Returns

CurlSettings

WithHeader(string, string)

Add a header.

public CurlSettings WithHeader(string key, string value)

Parameters

key string
value string

Returns

CurlSettings

WithHeaders(Dictionary<string, string>)

Add multiple headers.

public CurlSettings WithHeaders(Dictionary<string, string> headers)

Parameters

headers Dictionary<string, string>

Returns

CurlSettings

WithInsecure(bool)

Enable or disable SSL certificate validation.

public CurlSettings WithInsecure(bool insecure = true)

Parameters

insecure bool

Returns

CurlSettings

WithProgress(Action<double, long, long>)

Set progress callback.

public CurlSettings WithProgress(Action<double, long, long> callback)

Parameters

callback Action<double, long, long>

Returns

CurlSettings

WithProxy(string)

Set proxy.

public CurlSettings WithProxy(string proxyUrl)

Parameters

proxyUrl string

Returns

CurlSettings

WithProxy(string, string, string)

Set proxy with credentials.

public CurlSettings WithProxy(string proxyUrl, string username, string password)

Parameters

proxyUrl string
username string
password string

Returns

CurlSettings

WithRedirectHandler(Action<string>)

Set redirect callback.

public CurlSettings WithRedirectHandler(Action<string> callback)

Parameters

callback Action<string>

Returns

CurlSettings

WithRetries(int, int)

Set retry behavior.

public CurlSettings WithRetries(int count, int delayMs = 1000)

Parameters

count int
delayMs int

Returns

CurlSettings

WithTimeout(int)

Set maximum time for operation.

public CurlSettings WithTimeout(int seconds)

Parameters

seconds int

Returns

CurlSettings

WithUserAgent(string)

Set custom user agent.

public CurlSettings WithUserAgent(string userAgent)

Parameters

userAgent string

Returns

CurlSettings