pub struct HttpConfig {Show 14 fields
pub timeout: Duration,
pub connect_timeout: Duration,
pub max_retries: u32,
pub verbose: bool,
pub user_agent: String,
pub return_response_headers: bool,
pub proxy: Option<ProxyConfig>,
pub enable_rate_limit: bool,
pub retry_config: Option<RetryConfig>,
pub max_response_size: usize,
pub max_request_size: usize,
pub circuit_breaker: Option<CircuitBreakerConfig>,
pub pool_max_idle_per_host: usize,
pub pool_idle_timeout: Duration,
}Expand description
HTTP request configuration
Fields§
§timeout: DurationRequest timeout
connect_timeout: DurationTCP connection timeout (default: 10 seconds)
max_retries: u32Maximum retry attempts (deprecated, use retry_config instead)
verbose: boolWhether to enable verbose logging
user_agent: StringDefault User-Agent header value
return_response_headers: boolWhether to include response headers in the result
proxy: Option<ProxyConfig>Optional proxy configuration
enable_rate_limit: boolWhether to enable rate limiting
retry_config: Option<RetryConfig>Optional retry configuration (uses default if None)
max_response_size: usizeMaximum response body size in bytes (default: 10MB)
Responses exceeding this limit will be rejected with an InvalidRequest error.
This protects against malicious or abnormal responses that could exhaust memory.
max_request_size: usizeMaximum request body size in bytes (default: 10MB)
Request bodies exceeding this limit will be rejected BEFORE serialization. This protects against DoS attacks via oversized request payloads.
circuit_breaker: Option<CircuitBreakerConfig>Optional circuit breaker configuration.
When enabled, the circuit breaker will track request failures and automatically block requests to failing endpoints, allowing the system to recover.
Default: None (disabled for backward compatibility)
pool_max_idle_per_host: usizeMaximum number of idle connections per host in the connection pool.
This controls how many keep-alive connections are maintained for each host. Higher values improve performance for repeated requests to the same host but consume more resources.
Default: 10
pool_idle_timeout: DurationTimeout for idle connections in the pool.
Connections that have been idle longer than this duration will be closed. This helps free up resources and avoid stale connections.
Default: 90 seconds
Implementations§
Source§impl HttpConfig
impl HttpConfig
Sourcepub fn validate(&self) -> Result<ValidationResult, ConfigValidationError>
pub fn validate(&self) -> Result<ValidationResult, ConfigValidationError>
Validates the HTTP configuration parameters.
§Returns
Returns Ok(ValidationResult) if the configuration is valid.
The ValidationResult may contain warnings for suboptimal but valid configurations.
Returns Err(ConfigValidationError) if the configuration is invalid.
§Validation Rules
timeout> 5 minutes returns an error (excessive timeout)timeout< 1 second generates a warning (may cause frequent timeouts)
§Example
use ccxt_core::http_client::HttpConfig;
use std::time::Duration;
let config = HttpConfig::default();
let result = config.validate();
assert!(result.is_ok());
let invalid_config = HttpConfig {
timeout: Duration::from_secs(600), // 10 minutes - too long
..Default::default()
};
let result = invalid_config.validate();
assert!(result.is_err());Trait Implementations§
Source§impl Clone for HttpConfig
impl Clone for HttpConfig
Source§fn clone(&self) -> HttpConfig
fn clone(&self) -> HttpConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more