Skip to content

Commit

Permalink
v0.20.25
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 committed Aug 15, 2024
1 parent ef9348c commit d036e9a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rquest"
version = "0.20.23"
version = "0.20.25"
description = "An fast asynchronous Rust Http/WebSocket Client with TLS/JA3/JA4/HTTP2 fingerprint impersonate"
keywords = ["http", "client", "websocket", "ja3", "ja4"]
categories = ["web-programming::http-client"]
Expand Down
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,80 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
```

- Preconfigured `TLS`/`HTTP2`

```toml
[dependencies]
tokio = { version = "1", features = ["full"] }
rquest = "0.20"
```

```rust
use boring::ssl::{SslConnector, SslMethod};
use http::HeaderValue;
use rquest::{
tls::{Http2FrameSettings, TlsExtensionSettings, TlsSettings},
HttpVersionPref,
};
use rquest::{PseudoOrder, SettingsOrder, StreamDependency, StreamId};
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Create a pre-configured TLS settings
let settings = TlsSettings::builder()
.builder(SslConnector::builder(SslMethod::tls_client())?)
.extension(
TlsExtensionSettings::builder()
.tls_sni(true)
.http_version_pref(HttpVersionPref::All)
.application_settings(true)
.pre_shared_key(true)
.enable_ech_grease(true)
.permute_extensions(true)
.build(),
)
.http2(
Http2FrameSettings::builder()
.initial_stream_window_size(6291456)
.initial_connection_window_size(15728640)
.max_concurrent_streams(1000)
.max_header_list_size(262144)
.header_table_size(65536)
.enable_push(None)
.headers_priority(StreamDependency::new(StreamId::zero(), 255, true))
.headers_pseudo_order([
PseudoOrder::Method,
PseudoOrder::Scheme,
PseudoOrder::Authority,
PseudoOrder::Path,
])
.settings_order([
SettingsOrder::InitialWindowSize,
SettingsOrder::MaxConcurrentStreams,
])
.build(),
)
.build();

// Build a client with pre-configured TLS settings
let client = rquest::Client::builder()
.use_preconfigured_tls(settings, |headers| {
headers.insert("user-agent", HeaderValue::from_static("rquest"));
})
.enable_ech_grease()
.permute_extensions()
.build()?;

// Use the API you're already familiar with
let resp = client.get("https://tls.peet.ws/api/all").send().await?;
println!("{}", resp.text().await?);

Ok(())
}

```

## Requirement

Install the environment required to build [BoringSSL](https://github.com/google/boringssl/blob/master/BUILDING.md)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! - HTTP [Proxies](#proxies)
//! - Uses BoringSSL [TLS](#tls)
//! - `JA3`/`JA4`/`HTTP2` fingerprint
//! - [Preconfigured](#Preconfigured-TLS) `TLS`/`HTTP2` settings
//! - [Preconfigured](#preconfigured-tls) `TLS`/`HTTP2` settings
//! - Chrome / Safari / Edge / OkHttp [Fingerprint](#impersonate)
//! - [Changelog](https://github.com/0x676e67/rquest/blob/main/CHANGELOG.md)
//!
Expand Down

0 comments on commit d036e9a

Please sign in to comment.