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: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
[![PyPI - License](https://img.shields.io/pypi/l/rnet)](https://github.com/0x676e67/rnet/blob/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/rnet)](https://pypi.org/project/rnet/)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2F0x676e67%2Frnet%2Fmain%2Fpyproject.toml)
![PyPI - Format](https://img.shields.io/pypi/format/rnet)

> 🚀 Help me work seamlessly with open source sharing by [sponsoring me on GitHub](https://github.com/0x676e67/0x676e67/blob/main/SPONSOR.md)

An asynchronous Python HTTP client with Black Magic, powered by FFI from [rquest](https://github.com/0x676e67/rquest), capable of mimicking `TLS` and `HTTP2` configurations of popular browsers like `Chrome`, `Safari`, `Firefox`, and `OkHttp`.
An asynchronous Python HTTP client with Black Magic, powered by FFI from [rquest](https://github.com/0x676e67/rquest), capable of mimicking `TLS` and `HTTP2` fingerprints of popular browsers like `Chrome`, `Safari`, `Firefox`, and `OkHttp`.

## Features

Expand Down
25 changes: 24 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ macro_rules! apply_option {
/// A client for making HTTP requests.
#[gen_stub_pyclass]
#[pyclass]
#[derive(Default)]
pub struct Client(ArcSwap<rquest::Client>);

#[gen_stub_pymethods]
Expand Down Expand Up @@ -857,6 +856,30 @@ impl Client {
}
}

/// Creates a new default `Client` instance.
///
/// # Panics
///
/// This method will panic if the Client cannot be created.
///
/// # Examples
///
/// ```rust
/// use rnet::Client;
///
/// let client = Client::default();
/// ```
impl Default for Client {
fn default() -> Self {
rquest::Client::builder()
.no_hickory_dns()
.build()
.map(ArcSwap::from_pointee)
.map(Client)
.expect("Failed to build the default client.")
}
}

/// Executes an HTTP request.
async fn execute_request(
client: Guard<Arc<rquest::Client>>,
Expand Down