Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions python/rnet/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ class ClientParams(TypedDict, closed=True):
https_only: NotRequired[bool]
"""Enable HTTPS only."""

http2_max_retry_count: NotRequired[int]
"""Max HTTP/2 retry count."""

verify: NotRequired[Union[bool, Path, CertStore]]
"""Verify SSL or specify CA path."""

Expand Down
11 changes: 1 addition & 10 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct Builder {
tcp_keepalive_interval: Option<u64>,
/// Set the number of retries for TCP keepalive.
tcp_keepalive_retries: Option<u32>,
/// Set an optional user timeout for TCP sockets. (in seconds)
/// Set an optional user timeout for TCP sockets. (in seconds)
tcp_user_timeout: Option<u64>,
/// Set that all sockets have `NO_DELAY` set.
tcp_nodelay: Option<bool>,
Expand All @@ -117,8 +117,6 @@ pub struct Builder {
http2_only: Option<bool>,
/// Whether to use HTTPS only.
https_only: Option<bool>,
/// The maximum number of times to retry a client.
http2_max_retry_count: Option<usize>,

// ========= TLS options =========
/// Whether to verify the SSL certificate or root certificate file path.
Expand Down Expand Up @@ -193,7 +191,6 @@ impl<'py> FromPyObject<'py> for Builder {
extract_option!(ob, params, https_only);
extract_option!(ob, params, http1_only);
extract_option!(ob, params, http2_only);
extract_option!(ob, params, http2_max_retry_count);

extract_option!(ob, params, verify);
extract_option!(ob, params, identity);
Expand Down Expand Up @@ -479,12 +476,6 @@ impl Client {
apply_option!(set_if_true, builder, params.http1_only, http1_only, false);
apply_option!(set_if_true, builder, params.http2_only, http2_only, false);
apply_option!(set_if_some, builder, params.https_only, https_only);
apply_option!(
set_if_some,
builder,
params.http2_max_retry_count,
http2_max_retry
);

// TLS options.
apply_option!(
Expand Down
39 changes: 39 additions & 0 deletions src/client/req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,80 @@ use crate::{

/// The parameters for a request.
#[derive(Default)]
#[non_exhaustive]
pub struct Request {
/// The Emulation settings for the request.
pub emulation: Option<Extractor<EmulationOption>>,

/// The proxy to use for the request.
pub proxy: Option<Extractor<Proxy>>,

/// Bind to a local IP Address.
pub local_address: Option<Extractor<IpAddr>>,

/// Bind to an interface by `SO_BINDTODEVICE`.
pub interface: Option<String>,

/// The timeout to use for the request.
pub timeout: Option<u64>,

/// The read timeout to use for the request.
pub read_timeout: Option<u64>,

/// The HTTP version to use for the request.
pub version: Option<Extractor<Version>>,

/// The headers to use for the request.
pub headers: Option<Extractor<HeaderMap>>,

/// The original headers to use for the request.
pub orig_headers: Option<Extractor<OrigHeaderMap>>,

/// The option enables default headers.
pub default_headers: Option<bool>,

/// The cookies to use for the request.
pub cookies: Option<Extractor<Vec<HeaderValue>>>,

/// Whether to allow redirects.
pub allow_redirects: Option<bool>,

/// The maximum number of redirects to follow.
pub max_redirects: Option<usize>,

/// Sets gzip as an accepted encoding.
pub gzip: Option<bool>,

/// Sets brotli as an accepted encoding.
pub brotli: Option<bool>,

/// Sets deflate as an accepted encoding.
pub deflate: Option<bool>,

/// Sets zstd as an accepted encoding.
pub zstd: Option<bool>,

/// The authentication to use for the request.
pub auth: Option<PyBackedStr>,

/// The bearer authentication to use for the request.
pub bearer_auth: Option<PyBackedStr>,

/// The basic authentication to use for the request.
pub basic_auth: Option<(PyBackedStr, Option<PyBackedStr>)>,

/// The query parameters to use for the request.
pub query: Option<Extractor<Vec<(PyBackedStr, PyBackedStr)>>>,

/// The form parameters to use for the request.
pub form: Option<Extractor<Vec<(PyBackedStr, PyBackedStr)>>>,

/// The JSON body to use for the request.
pub json: Option<Json>,

/// The body to use for the request.
pub body: Option<Body>,

/// The multipart form to use for the request.
pub multipart: Option<Extractor<Form>>,
}
Expand Down Expand Up @@ -105,33 +130,47 @@ impl<'py> FromPyObject<'py> for Request {

/// The parameters for a WebSocket request.
#[derive(Default)]
#[non_exhaustive]
pub struct WebSocketRequest {
/// The Emulation settings for the request.
pub emulation: Option<Extractor<EmulationOption>>,

/// The proxy to use for the request.
pub proxy: Option<Extractor<Proxy>>,

/// Bind to a local IP Address.
pub local_address: Option<Extractor<IpAddr>>,

/// Bind to an interface by `SO_BINDTODEVICE`.
pub interface: Option<String>,

/// The headers to use for the request.
pub headers: Option<Extractor<HeaderMap>>,

/// The original headers to use for the request.
pub orig_headers: Option<Extractor<OrigHeaderMap>>,

/// The option enables default headers.
pub default_headers: Option<bool>,

/// The cookies to use for the request.
pub cookies: Option<Extractor<Vec<HeaderValue>>>,

/// The protocols to use for the request.
pub protocols: Option<Vec<String>>,

/// Whether to use HTTP/2 for the websocket.
pub force_http2: Option<bool>,

/// The authentication to use for the request.
pub auth: Option<PyBackedStr>,

/// The bearer authentication to use for the request.
pub bearer_auth: Option<PyBackedStr>,

/// The basic authentication to use for the request.
pub basic_auth: Option<(PyBackedStr, Option<PyBackedStr>)>,

/// The query parameters to use for the request.
pub query: Option<Extractor<Vec<(PyBackedStr, PyBackedStr)>>>,

Expand Down
Loading