wreq 1.3.2.4 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +470 -50
- data/Cargo.toml +19 -16
- data/README.md +5 -12
- data/Rakefile +3 -9
- data/crates/wreq-util/Cargo.toml +1 -1
- data/crates/wreq-util/README.md +4 -2
- data/crates/wreq-util/examples/emulate.rs +7 -3
- data/crates/wreq-util/examples/tower_delay.rs +4 -4
- data/crates/wreq-util/src/emulate/macros.rs +197 -32
- data/crates/wreq-util/src/emulate/profile/chrome/header.rs +116 -0
- data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +65 -0
- data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +268 -0
- data/crates/wreq-util/src/emulate/profile/chrome.rs +2269 -0
- data/crates/wreq-util/src/emulate/profile/firefox/header.rs +54 -48
- data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +102 -92
- data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +146 -155
- data/crates/wreq-util/src/emulate/profile/firefox.rs +440 -312
- data/crates/wreq-util/src/emulate/profile/okhttp.rs +2 -3
- data/crates/wreq-util/src/emulate/profile/opera/header.rs +29 -0
- data/crates/wreq-util/src/emulate/profile/opera/http2.rs +50 -0
- data/crates/wreq-util/src/emulate/profile/opera/tls.rs +103 -0
- data/crates/wreq-util/src/emulate/profile/opera.rs +299 -0
- data/crates/wreq-util/src/emulate/profile.rs +10 -10
- data/crates/wreq-util/src/emulate.rs +1 -34
- data/crates/wreq-util/src/tower/delay/layer.rs +5 -5
- data/crates/wreq-util/src/tower/delay.rs +4 -4
- data/crates/wreq-util/tests/client.rs +50 -187
- data/crates/wreq-util/tests/emulate_chrome.rs +0 -17
- data/crates/wreq-util/tests/emulate_firefox.rs +26 -36
- data/crates/wreq-util/tests/emulate_opera.rs +0 -24
- data/crates/wreq-util/tests/support/mod.rs +1 -1
- data/lib/wreq_ruby/client.rb +27 -13
- data/lib/wreq_ruby/emulate.rb +3 -28
- data/lib/wreq_ruby/http.rb +9 -2
- data/src/client/body/json.rs +1 -2
- data/src/client/resp.rs +1 -1
- data/src/client.rs +8 -4
- data/src/emulate.rs +5 -28
- data/src/error.rs +23 -3
- data/src/lib.rs +3 -2
- data/src/options.rs +17 -19
- data/{crates/serde-magnus/src → src/serde}/de/array_deserializer.rs +2 -2
- data/{crates/serde-magnus/src → src/serde}/de/array_enumerator.rs +1 -1
- data/{crates/serde-magnus/src → src/serde}/de/deserializer.rs +31 -25
- data/{crates/serde-magnus/src → src/serde}/de/enum_deserializer.rs +3 -3
- data/{crates/serde-magnus/src → src/serde}/de/hash_deserializer.rs +2 -2
- data/{crates/serde-magnus/src → src/serde}/de/number_deserializer.rs +2 -2
- data/{crates/serde-magnus/src → src/serde}/de/variant_deserializer.rs +20 -11
- data/src/serde/de.rs +33 -0
- data/src/serde/error.rs +146 -0
- data/src/serde/ser/enums.rs +14 -0
- data/{crates/serde-magnus/src → src/serde}/ser/map_serializer.rs +2 -2
- data/src/serde/ser/seq_serializer.rs +71 -0
- data/src/serde/ser/serializer.rs +194 -0
- data/{crates/serde-magnus/src → src/serde}/ser/struct_serializer.rs +4 -4
- data/src/serde/ser/struct_variant_serializer.rs +44 -0
- data/src/serde/ser/tuple_variant_serializer.rs +41 -0
- data/src/serde/ser.rs +18 -0
- data/{crates/serde-magnus/src → src/serde}/tests.rs +68 -19
- data/src/serde.rs +202 -0
- data/test/emulation_test.rb +104 -21
- data/test/option_validation_test.rb +13 -4
- data/wreq.gemspec +15 -3
- metadata +29 -35
- data/VERSION +0 -1
- data/crates/README.md +0 -6
- data/crates/serde-magnus/Cargo.toml +0 -29
- data/crates/serde-magnus/LICENSE +0 -19
- data/crates/serde-magnus/README.md +0 -147
- data/crates/serde-magnus/src/de/mod.rs +0 -554
- data/crates/serde-magnus/src/error.rs +0 -84
- data/crates/serde-magnus/src/lib.rs +0 -137
- data/crates/serde-magnus/src/options.rs +0 -151
- data/crates/serde-magnus/src/ser/enums.rs +0 -11
- data/crates/serde-magnus/src/ser/mod.rs +0 -428
- data/crates/serde-magnus/src/ser/seq_serializer.rs +0 -68
- data/crates/serde-magnus/src/ser/serializer.rs +0 -220
- data/crates/serde-magnus/src/ser/struct_variant_serializer.rs +0 -45
- data/crates/serde-magnus/src/ser/tuple_variant_serializer.rs +0 -38
- data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +0 -731
- data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +0 -418
- data/crates/wreq-util/src/emulate/profile/chromium/header.rs +0 -74
- data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +0 -59
- data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +0 -312
- data/crates/wreq-util/src/emulate/profile/chromium/tls.rs +0 -310
- data/crates/wreq-util/src/emulate/profile/chromium.rs +0 -9
- data/test/emulation_client_hello_test.rb +0 -142
|
@@ -69,14 +69,13 @@ macro_rules! mod_generator {
|
|
|
69
69
|
use super::*;
|
|
70
70
|
|
|
71
71
|
pub fn emulation(emulation: Emulation) -> wreq::Emulation {
|
|
72
|
-
build_emulation(
|
|
72
|
+
build_emulation(emulation, $cipher, $ua)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
fn build_emulation(
|
|
79
|
-
group: &'static str,
|
|
80
79
|
emulation: Emulation,
|
|
81
80
|
cipher_list: &'static str,
|
|
82
81
|
user_agent: &'static str,
|
|
@@ -127,7 +126,7 @@ fn build_emulation(
|
|
|
127
126
|
headers
|
|
128
127
|
});
|
|
129
128
|
|
|
130
|
-
build_standard_emulation(
|
|
129
|
+
build_standard_emulation(tls_options, http2_options, headers)
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
mod_generator!(
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
#[inline]
|
|
4
|
+
pub fn header_initializer_with_zstd_priority(
|
|
5
|
+
sec_ch_ua: &'static str,
|
|
6
|
+
ua: &'static str,
|
|
7
|
+
emulation_os: Platform,
|
|
8
|
+
) -> HeaderMap {
|
|
9
|
+
let mut headers = HeaderMap::new();
|
|
10
|
+
header_chrome_sec_ch_ua!(
|
|
11
|
+
headers,
|
|
12
|
+
sec_ch_ua,
|
|
13
|
+
emulation_os.platform(),
|
|
14
|
+
emulation_os.is_mobile()
|
|
15
|
+
);
|
|
16
|
+
headers.insert(
|
|
17
|
+
HeaderName::from_static("upgrade-insecure-requests"),
|
|
18
|
+
HeaderValue::from_static("1"),
|
|
19
|
+
);
|
|
20
|
+
header_chrome_ua!(headers, ua);
|
|
21
|
+
header_chrome_accept!(headers);
|
|
22
|
+
header_chrome_sec_fetch!(headers);
|
|
23
|
+
header_chrome_accept_encoding!(zstd, headers);
|
|
24
|
+
headers.insert(
|
|
25
|
+
HeaderName::from_static("priority"),
|
|
26
|
+
HeaderValue::from_static("u=0, i"),
|
|
27
|
+
);
|
|
28
|
+
headers
|
|
29
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
macro_rules! headers_priority {
|
|
2
|
+
() => {
|
|
3
|
+
HeadersPriority::new(HeadersDependency::Root, 255, true)
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
macro_rules! pseudo_order {
|
|
8
|
+
() => {
|
|
9
|
+
PseudoOrder::builder()
|
|
10
|
+
.extend([
|
|
11
|
+
PseudoId::Method,
|
|
12
|
+
PseudoId::Authority,
|
|
13
|
+
PseudoId::Scheme,
|
|
14
|
+
PseudoId::Path,
|
|
15
|
+
])
|
|
16
|
+
.build()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
macro_rules! settings_order {
|
|
21
|
+
() => {
|
|
22
|
+
SettingsOrder::builder()
|
|
23
|
+
.extend([
|
|
24
|
+
SettingId::HeaderTableSize,
|
|
25
|
+
SettingId::EnablePush,
|
|
26
|
+
SettingId::MaxConcurrentStreams,
|
|
27
|
+
SettingId::InitialWindowSize,
|
|
28
|
+
SettingId::MaxFrameSize,
|
|
29
|
+
SettingId::MaxHeaderListSize,
|
|
30
|
+
SettingId::EnableConnectProtocol,
|
|
31
|
+
SettingId::NoRfc7540Priorities,
|
|
32
|
+
])
|
|
33
|
+
.build()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
macro_rules! http2_options {
|
|
38
|
+
() => {
|
|
39
|
+
Http2Options::builder()
|
|
40
|
+
.initial_window_size(6291456)
|
|
41
|
+
.initial_connection_window_size(15728640)
|
|
42
|
+
.max_header_list_size(262144)
|
|
43
|
+
.header_table_size(65536)
|
|
44
|
+
.enable_push(false)
|
|
45
|
+
.headers_priority(headers_priority!())
|
|
46
|
+
.headers_pseudo_order(pseudo_order!())
|
|
47
|
+
.settings_order(settings_order!())
|
|
48
|
+
.build()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
macro_rules! tls_options {
|
|
4
|
+
($curves:expr) => {
|
|
5
|
+
OperaTlsConfig::builder()
|
|
6
|
+
.curves($curves)
|
|
7
|
+
.permute_extensions(true)
|
|
8
|
+
.pre_shared_key(true)
|
|
9
|
+
.enable_ech_grease(true)
|
|
10
|
+
.build()
|
|
11
|
+
.into()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
pub const CURVES: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
|
|
16
|
+
|
|
17
|
+
pub const CIPHER_LIST: &str = join!(
|
|
18
|
+
":",
|
|
19
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
20
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
21
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
22
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
23
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
24
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
25
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
26
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
27
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
28
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
29
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
30
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[
|
|
34
|
+
Tls13Cipher::AES_128_GCM_SHA256,
|
|
35
|
+
Tls13Cipher::AES_256_GCM_SHA384,
|
|
36
|
+
Tls13Cipher::CHACHA20_POLY1305_SHA256,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
pub const SIGALGS_LIST: &str = join!(
|
|
40
|
+
":",
|
|
41
|
+
"ecdsa_secp256r1_sha256",
|
|
42
|
+
"rsa_pss_rsae_sha256",
|
|
43
|
+
"rsa_pkcs1_sha256",
|
|
44
|
+
"ecdsa_secp384r1_sha384",
|
|
45
|
+
"rsa_pss_rsae_sha384",
|
|
46
|
+
"rsa_pkcs1_sha384",
|
|
47
|
+
"rsa_pss_rsae_sha512",
|
|
48
|
+
"rsa_pkcs1_sha512"
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor];
|
|
52
|
+
|
|
53
|
+
#[derive(TypedBuilder)]
|
|
54
|
+
pub struct OperaTlsConfig {
|
|
55
|
+
#[builder(default = CURVES)]
|
|
56
|
+
curves: &'static str,
|
|
57
|
+
|
|
58
|
+
#[builder(default = SIGALGS_LIST)]
|
|
59
|
+
sigalgs_list: &'static str,
|
|
60
|
+
|
|
61
|
+
#[builder(default = CIPHER_LIST)]
|
|
62
|
+
cipher_list: &'static str,
|
|
63
|
+
|
|
64
|
+
#[builder(default = AlpsProtocol::HTTP2, setter(into))]
|
|
65
|
+
alps_protos: AlpsProtocol,
|
|
66
|
+
|
|
67
|
+
#[builder(default = false)]
|
|
68
|
+
alps_use_new_codepoint: bool,
|
|
69
|
+
|
|
70
|
+
#[builder(default = false, setter(into))]
|
|
71
|
+
enable_ech_grease: bool,
|
|
72
|
+
|
|
73
|
+
#[builder(default = false, setter(into))]
|
|
74
|
+
permute_extensions: bool,
|
|
75
|
+
|
|
76
|
+
#[builder(default = false, setter(into))]
|
|
77
|
+
pre_shared_key: bool,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl From<OperaTlsConfig> for TlsOptions {
|
|
81
|
+
fn from(val: OperaTlsConfig) -> Self {
|
|
82
|
+
TlsOptions::builder()
|
|
83
|
+
.grease_enabled(true)
|
|
84
|
+
.enable_ocsp_stapling(true)
|
|
85
|
+
.enable_signed_cert_timestamps(true)
|
|
86
|
+
.curves_list(val.curves)
|
|
87
|
+
.sigalgs_list(val.sigalgs_list)
|
|
88
|
+
.cipher_list(val.cipher_list)
|
|
89
|
+
.tls13_cipher_list(TLS13_CIPHER_LIST)
|
|
90
|
+
.min_tls_version(TlsVersion::TLS_1_2)
|
|
91
|
+
.max_tls_version(TlsVersion::TLS_1_3)
|
|
92
|
+
.permute_extensions(val.permute_extensions)
|
|
93
|
+
.pre_shared_key(val.pre_shared_key)
|
|
94
|
+
.ech_grease(
|
|
95
|
+
val.enable_ech_grease
|
|
96
|
+
.then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)),
|
|
97
|
+
)
|
|
98
|
+
.alps_protocols([val.alps_protos])
|
|
99
|
+
.alps_use_new_codepoint(val.alps_use_new_codepoint)
|
|
100
|
+
.certificate_compressors(CERTIFICATE_COMPRESSORS)
|
|
101
|
+
.build()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
#[macro_use]
|
|
2
|
+
mod http2;
|
|
3
|
+
#[macro_use]
|
|
4
|
+
mod tls;
|
|
5
|
+
mod header;
|
|
6
|
+
|
|
7
|
+
use header::*;
|
|
8
|
+
use tls::*;
|
|
9
|
+
|
|
10
|
+
use super::*;
|
|
11
|
+
|
|
12
|
+
mod_generator!(
|
|
13
|
+
opera116,
|
|
14
|
+
tls_options!(CURVES),
|
|
15
|
+
http2_options!(),
|
|
16
|
+
header_initializer_with_zstd_priority,
|
|
17
|
+
[
|
|
18
|
+
(
|
|
19
|
+
MacOS,
|
|
20
|
+
r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#,
|
|
21
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"
|
|
22
|
+
),
|
|
23
|
+
(
|
|
24
|
+
Windows,
|
|
25
|
+
r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#,
|
|
26
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
mod_generator!(
|
|
32
|
+
opera117,
|
|
33
|
+
opera116::build_emulation,
|
|
34
|
+
header_initializer_with_zstd_priority,
|
|
35
|
+
[
|
|
36
|
+
(
|
|
37
|
+
MacOS,
|
|
38
|
+
r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#,
|
|
39
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"
|
|
40
|
+
),
|
|
41
|
+
(
|
|
42
|
+
Windows,
|
|
43
|
+
r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#,
|
|
44
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"
|
|
45
|
+
)
|
|
46
|
+
]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
mod_generator!(
|
|
50
|
+
opera118,
|
|
51
|
+
opera116::build_emulation,
|
|
52
|
+
header_initializer_with_zstd_priority,
|
|
53
|
+
[
|
|
54
|
+
(
|
|
55
|
+
MacOS,
|
|
56
|
+
r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#,
|
|
57
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"
|
|
58
|
+
),
|
|
59
|
+
(
|
|
60
|
+
Windows,
|
|
61
|
+
r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#,
|
|
62
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
mod_generator!(
|
|
68
|
+
opera119,
|
|
69
|
+
opera116::build_emulation,
|
|
70
|
+
header_initializer_with_zstd_priority,
|
|
71
|
+
[
|
|
72
|
+
(
|
|
73
|
+
MacOS,
|
|
74
|
+
r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#,
|
|
75
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"
|
|
76
|
+
),
|
|
77
|
+
(
|
|
78
|
+
Windows,
|
|
79
|
+
r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#,
|
|
80
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"
|
|
81
|
+
)
|
|
82
|
+
]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
mod_generator!(
|
|
86
|
+
opera120,
|
|
87
|
+
opera116::build_emulation,
|
|
88
|
+
header_initializer_with_zstd_priority,
|
|
89
|
+
[
|
|
90
|
+
(
|
|
91
|
+
MacOS,
|
|
92
|
+
r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#,
|
|
93
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"
|
|
94
|
+
),
|
|
95
|
+
(
|
|
96
|
+
Windows,
|
|
97
|
+
r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#,
|
|
98
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
mod_generator!(
|
|
104
|
+
opera121,
|
|
105
|
+
opera116::build_emulation,
|
|
106
|
+
header_initializer_with_zstd_priority,
|
|
107
|
+
[
|
|
108
|
+
(
|
|
109
|
+
MacOS,
|
|
110
|
+
r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#,
|
|
111
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"
|
|
112
|
+
),
|
|
113
|
+
(
|
|
114
|
+
Windows,
|
|
115
|
+
r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#,
|
|
116
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"
|
|
117
|
+
)
|
|
118
|
+
]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
mod_generator!(
|
|
122
|
+
opera122,
|
|
123
|
+
opera116::build_emulation,
|
|
124
|
+
header_initializer_with_zstd_priority,
|
|
125
|
+
[
|
|
126
|
+
(
|
|
127
|
+
MacOS,
|
|
128
|
+
r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#,
|
|
129
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"
|
|
130
|
+
),
|
|
131
|
+
(
|
|
132
|
+
Windows,
|
|
133
|
+
r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#,
|
|
134
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
mod_generator!(
|
|
140
|
+
opera123,
|
|
141
|
+
opera116::build_emulation,
|
|
142
|
+
header_initializer_with_zstd_priority,
|
|
143
|
+
[
|
|
144
|
+
(
|
|
145
|
+
MacOS,
|
|
146
|
+
r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#,
|
|
147
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"
|
|
148
|
+
),
|
|
149
|
+
(
|
|
150
|
+
Windows,
|
|
151
|
+
r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#,
|
|
152
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"
|
|
153
|
+
)
|
|
154
|
+
]
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
mod_generator!(
|
|
158
|
+
opera124,
|
|
159
|
+
opera116::build_emulation,
|
|
160
|
+
header_initializer_with_zstd_priority,
|
|
161
|
+
[
|
|
162
|
+
(
|
|
163
|
+
MacOS,
|
|
164
|
+
r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#,
|
|
165
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"
|
|
166
|
+
),
|
|
167
|
+
(
|
|
168
|
+
Windows,
|
|
169
|
+
r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#,
|
|
170
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"
|
|
171
|
+
)
|
|
172
|
+
]
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
mod_generator!(
|
|
176
|
+
opera125,
|
|
177
|
+
opera116::build_emulation,
|
|
178
|
+
header_initializer_with_zstd_priority,
|
|
179
|
+
[
|
|
180
|
+
(
|
|
181
|
+
MacOS,
|
|
182
|
+
r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#,
|
|
183
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"
|
|
184
|
+
),
|
|
185
|
+
(
|
|
186
|
+
Windows,
|
|
187
|
+
r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#,
|
|
188
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"
|
|
189
|
+
)
|
|
190
|
+
]
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
mod_generator!(
|
|
194
|
+
opera126,
|
|
195
|
+
opera116::build_emulation,
|
|
196
|
+
header_initializer_with_zstd_priority,
|
|
197
|
+
[
|
|
198
|
+
(
|
|
199
|
+
MacOS,
|
|
200
|
+
r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#,
|
|
201
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"
|
|
202
|
+
),
|
|
203
|
+
(
|
|
204
|
+
Windows,
|
|
205
|
+
r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#,
|
|
206
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"
|
|
207
|
+
)
|
|
208
|
+
]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
mod_generator!(
|
|
212
|
+
opera127,
|
|
213
|
+
opera116::build_emulation,
|
|
214
|
+
header_initializer_with_zstd_priority,
|
|
215
|
+
[
|
|
216
|
+
(
|
|
217
|
+
MacOS,
|
|
218
|
+
r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#,
|
|
219
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"
|
|
220
|
+
),
|
|
221
|
+
(
|
|
222
|
+
Windows,
|
|
223
|
+
r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#,
|
|
224
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"
|
|
225
|
+
)
|
|
226
|
+
]
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
mod_generator!(
|
|
230
|
+
opera128,
|
|
231
|
+
opera116::build_emulation,
|
|
232
|
+
header_initializer_with_zstd_priority,
|
|
233
|
+
[
|
|
234
|
+
(
|
|
235
|
+
MacOS,
|
|
236
|
+
r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#,
|
|
237
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"
|
|
238
|
+
),
|
|
239
|
+
(
|
|
240
|
+
Windows,
|
|
241
|
+
r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#,
|
|
242
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"
|
|
243
|
+
)
|
|
244
|
+
]
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
mod_generator!(
|
|
248
|
+
opera129,
|
|
249
|
+
opera116::build_emulation,
|
|
250
|
+
header_initializer_with_zstd_priority,
|
|
251
|
+
[
|
|
252
|
+
(
|
|
253
|
+
MacOS,
|
|
254
|
+
r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#,
|
|
255
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"
|
|
256
|
+
),
|
|
257
|
+
(
|
|
258
|
+
Windows,
|
|
259
|
+
r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#,
|
|
260
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"
|
|
261
|
+
)
|
|
262
|
+
]
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
mod_generator!(
|
|
266
|
+
opera130,
|
|
267
|
+
opera116::build_emulation,
|
|
268
|
+
header_initializer_with_zstd_priority,
|
|
269
|
+
[
|
|
270
|
+
(
|
|
271
|
+
MacOS,
|
|
272
|
+
r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#,
|
|
273
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"
|
|
274
|
+
),
|
|
275
|
+
(
|
|
276
|
+
Windows,
|
|
277
|
+
r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#,
|
|
278
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"
|
|
279
|
+
)
|
|
280
|
+
]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
mod_generator!(
|
|
284
|
+
opera131,
|
|
285
|
+
opera116::build_emulation,
|
|
286
|
+
header_initializer_with_zstd_priority,
|
|
287
|
+
[
|
|
288
|
+
(
|
|
289
|
+
MacOS,
|
|
290
|
+
r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#,
|
|
291
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"
|
|
292
|
+
),
|
|
293
|
+
(
|
|
294
|
+
Windows,
|
|
295
|
+
r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#,
|
|
296
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"
|
|
297
|
+
)
|
|
298
|
+
]
|
|
299
|
+
);
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
//! Emulation for different browsers.
|
|
2
2
|
|
|
3
|
-
pub
|
|
3
|
+
pub mod chrome;
|
|
4
4
|
pub mod firefox;
|
|
5
5
|
pub mod okhttp;
|
|
6
|
+
pub mod opera;
|
|
6
7
|
pub mod safari;
|
|
7
8
|
|
|
8
|
-
pub use chromium::{chrome, opera};
|
|
9
|
-
|
|
10
9
|
use typed_builder::TypedBuilder;
|
|
11
10
|
#[cfg(feature = "emulation-compression")]
|
|
12
11
|
use wreq::header::ACCEPT_ENCODING;
|
|
13
12
|
use wreq::{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
header::{ACCEPT, ACCEPT_LANGUAGE, HeaderMap, HeaderName, HeaderValue, USER_AGENT},
|
|
14
|
+
http2::{
|
|
15
|
+
HeadersDependency, HeadersPriority, Http2Options, Priorities, Priority, PseudoId,
|
|
16
|
+
PseudoOrder, SettingId, SettingsOrder, StreamDependency, StreamId,
|
|
17
|
+
},
|
|
17
18
|
tls::{
|
|
18
19
|
AlpnProtocol, AlpsProtocol, EchGrease, EchGreaseAead, ExtensionType, KeyShare, Tls13Cipher,
|
|
19
20
|
TlsOptions, TlsVersion, compress::CertificateCompressor,
|
|
@@ -26,20 +27,19 @@ use super::{
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
fn build_standard_emulation(
|
|
29
|
-
group: &'static str,
|
|
30
30
|
tls_options: TlsOptions,
|
|
31
31
|
http2_options: Option<Http2Options>,
|
|
32
32
|
default_headers: Option<HeaderMap>,
|
|
33
33
|
) -> wreq::Emulation {
|
|
34
|
-
let mut builder = wreq::Emulation::builder().
|
|
34
|
+
let mut builder = wreq::Emulation::builder().config(tls_options);
|
|
35
35
|
|
|
36
36
|
if let Some(http2_options) = http2_options {
|
|
37
|
-
builder = builder.
|
|
37
|
+
builder = builder.config(http2_options);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if let Some(headers) = default_headers {
|
|
41
41
|
builder = builder.headers(headers);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
builder.build(
|
|
44
|
+
builder.build()
|
|
45
45
|
}
|
|
@@ -3,12 +3,7 @@ mod macros;
|
|
|
3
3
|
pub mod compress;
|
|
4
4
|
pub mod profile;
|
|
5
5
|
|
|
6
|
-
use profile::{
|
|
7
|
-
chromium::{chrome::*, edge::*, opera::*},
|
|
8
|
-
firefox::*,
|
|
9
|
-
okhttp::*,
|
|
10
|
-
safari::*,
|
|
11
|
-
};
|
|
6
|
+
use profile::{chrome::*, firefox::*, okhttp::*, opera::*, safari::*};
|
|
12
7
|
#[cfg(feature = "emulation-serde")]
|
|
13
8
|
use serde::{Deserialize, Serialize};
|
|
14
9
|
use typed_builder::TypedBuilder;
|
|
@@ -73,7 +68,6 @@ define_enum!(
|
|
|
73
68
|
Chrome155 => ("chrome_155", v155::emulation),
|
|
74
69
|
Chrome156 => ("chrome_156", v156::emulation),
|
|
75
70
|
Chrome157 => ("chrome_157", v157::emulation),
|
|
76
|
-
Chrome158 => ("chrome_158", v158::emulation),
|
|
77
71
|
|
|
78
72
|
// Edge versions
|
|
79
73
|
Edge101 => ("edge_101", edge101::emulation),
|
|
@@ -95,16 +89,6 @@ define_enum!(
|
|
|
95
89
|
Edge146 => ("edge_146", edge146::emulation),
|
|
96
90
|
Edge147 => ("edge_147", edge147::emulation),
|
|
97
91
|
Edge148 => ("edge_148", edge148::emulation),
|
|
98
|
-
Edge149 => ("edge_149", edge149::emulation),
|
|
99
|
-
Edge150 => ("edge_150", edge150::emulation),
|
|
100
|
-
Edge151 => ("edge_151", edge151::emulation),
|
|
101
|
-
Edge152 => ("edge_152", edge152::emulation),
|
|
102
|
-
Edge153 => ("edge_153", edge153::emulation),
|
|
103
|
-
Edge154 => ("edge_154", edge154::emulation),
|
|
104
|
-
Edge155 => ("edge_155", edge155::emulation),
|
|
105
|
-
Edge156 => ("edge_156", edge156::emulation),
|
|
106
|
-
Edge157 => ("edge_157", edge157::emulation),
|
|
107
|
-
Edge158 => ("edge_158", edge158::emulation),
|
|
108
92
|
|
|
109
93
|
// Opera versions
|
|
110
94
|
Opera116 => ("opera_116", opera116::emulation),
|
|
@@ -123,15 +107,6 @@ define_enum!(
|
|
|
123
107
|
Opera129 => ("opera_129", opera129::emulation),
|
|
124
108
|
Opera130 => ("opera_130", opera130::emulation),
|
|
125
109
|
Opera131 => ("opera_131", opera131::emulation),
|
|
126
|
-
Opera132 => ("opera_132", opera132::emulation),
|
|
127
|
-
Opera133 => ("opera_133", opera133::emulation),
|
|
128
|
-
Opera134 => ("opera_134", opera134::emulation),
|
|
129
|
-
Opera135 => ("opera_135", opera135::emulation),
|
|
130
|
-
Opera136 => ("opera_136", opera136::emulation),
|
|
131
|
-
Opera137 => ("opera_137", opera137::emulation),
|
|
132
|
-
Opera138 => ("opera_138", opera138::emulation),
|
|
133
|
-
Opera139 => ("opera_139", opera139::emulation),
|
|
134
|
-
Opera140 => ("opera_140", opera140::emulation),
|
|
135
110
|
|
|
136
111
|
// Firefox versions
|
|
137
112
|
Firefox109 => ("firefox_109", ff109::emulation),
|
|
@@ -155,14 +130,6 @@ define_enum!(
|
|
|
155
130
|
Firefox150 => ("firefox_150", ff150::emulation),
|
|
156
131
|
Firefox151 => ("firefox_151", ff151::emulation),
|
|
157
132
|
Firefox152 => ("firefox_152", ff152::emulation),
|
|
158
|
-
Firefox153 => ("firefox_153", ff153::emulation),
|
|
159
|
-
Firefox154 => ("firefox_154", ff154::emulation),
|
|
160
|
-
Firefox155 => ("firefox_155", ff155::emulation),
|
|
161
|
-
Firefox156 => ("firefox_156", ff156::emulation),
|
|
162
|
-
Firefox157 => ("firefox_157", ff157::emulation),
|
|
163
|
-
Firefox158 => ("firefox_158", ff158::emulation),
|
|
164
|
-
Firefox159 => ("firefox_159", ff159::emulation),
|
|
165
|
-
Firefox160 => ("firefox_160", ff160::emulation),
|
|
166
133
|
|
|
167
134
|
// Safari versions
|
|
168
135
|
SafariIos17_2 => ("safari_ios_17.2", safari_ios_17_2::emulation),
|
|
@@ -29,10 +29,10 @@ pub struct DelayLayerWith<P> {
|
|
|
29
29
|
/// ```no_run
|
|
30
30
|
/// use std::time::Duration;
|
|
31
31
|
/// use wreq::Client;
|
|
32
|
-
/// use wreq_util::
|
|
32
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
33
33
|
///
|
|
34
34
|
/// // Creates delays in range [0.8s, 1.2s] (1s ± 20%)
|
|
35
|
-
/// let client = Client::
|
|
35
|
+
/// let client = Client::builder_tokio()
|
|
36
36
|
/// .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2))
|
|
37
37
|
/// .build()?;
|
|
38
38
|
/// # Ok::<(), wreq::Error>(())
|
|
@@ -71,7 +71,7 @@ impl DelayLayer {
|
|
|
71
71
|
/// ```ignore
|
|
72
72
|
/// use std::time::Duration;
|
|
73
73
|
/// use http::Request;
|
|
74
|
-
/// use wreq_util::
|
|
74
|
+
/// use wreq_util::tower::delay::DelayLayer;
|
|
75
75
|
///
|
|
76
76
|
/// // Only delay POST requests
|
|
77
77
|
/// let layer = DelayLayer::new(Duration::from_secs(1))
|
|
@@ -129,7 +129,7 @@ impl JitterDelayLayer {
|
|
|
129
129
|
///
|
|
130
130
|
/// ```
|
|
131
131
|
/// use std::time::Duration;
|
|
132
|
-
/// use wreq_util::
|
|
132
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
133
133
|
///
|
|
134
134
|
/// // Creates delays in range [800ms, 1200ms]
|
|
135
135
|
/// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2);
|
|
@@ -151,7 +151,7 @@ impl JitterDelayLayer {
|
|
|
151
151
|
/// ```ignore
|
|
152
152
|
/// use std::time::Duration;
|
|
153
153
|
/// use http::Request;
|
|
154
|
-
/// use wreq_util::
|
|
154
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
155
155
|
///
|
|
156
156
|
/// // Only delay requests to paths starting with "/slow"
|
|
157
157
|
/// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2)
|