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
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
use std::ffi::c_long;
|
|
2
|
-
|
|
3
|
-
use magnus::{IntoValue, RHash, Ruby, Value};
|
|
4
|
-
use serde::Serialize;
|
|
5
|
-
|
|
6
|
-
use super::{
|
|
7
|
-
MapSerializer, SeqSerializer, StructSerializer, StructVariantSerializer,
|
|
8
|
-
TupleVariantSerializer, enums::nest,
|
|
9
|
-
};
|
|
10
|
-
use crate::error::Error;
|
|
11
|
-
|
|
12
|
-
pub(super) struct Serializer<'r> {
|
|
13
|
-
ruby: &'r Ruby,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
impl<'r> Serializer<'r> {
|
|
17
|
-
pub fn new(ruby: &'r Ruby) -> Self {
|
|
18
|
-
Self { ruby }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
impl<'r> serde::Serializer for Serializer<'r> {
|
|
23
|
-
type Ok = Value;
|
|
24
|
-
type Error = Error;
|
|
25
|
-
|
|
26
|
-
type SerializeSeq = SeqSerializer<'r>;
|
|
27
|
-
type SerializeTuple = SeqSerializer<'r>;
|
|
28
|
-
type SerializeTupleStruct = SeqSerializer<'r>;
|
|
29
|
-
type SerializeTupleVariant = TupleVariantSerializer<'r>;
|
|
30
|
-
type SerializeMap = MapSerializer<'r>;
|
|
31
|
-
type SerializeStruct = StructSerializer<'r>;
|
|
32
|
-
type SerializeStructVariant = StructVariantSerializer<'r>;
|
|
33
|
-
|
|
34
|
-
fn serialize_bool(self, value: bool) -> Result<Self::Ok, Self::Error> {
|
|
35
|
-
Ok(value.into_value_with(self.ruby))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
fn serialize_i8(self, value: i8) -> Result<Self::Ok, Self::Error> {
|
|
39
|
-
Ok(value.into_value_with(self.ruby))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
fn serialize_i16(self, value: i16) -> Result<Self::Ok, Self::Error> {
|
|
43
|
-
Ok(value.into_value_with(self.ruby))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fn serialize_i32(self, value: i32) -> Result<Self::Ok, Self::Error> {
|
|
47
|
-
Ok(value.into_value_with(self.ruby))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
fn serialize_i64(self, value: i64) -> Result<Self::Ok, Self::Error> {
|
|
51
|
-
Ok(value.into_value_with(self.ruby))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
fn serialize_i128(self, value: i128) -> Result<Self::Ok, Self::Error> {
|
|
55
|
-
Ok(value.into_value_with(self.ruby))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
fn serialize_u8(self, value: u8) -> Result<Self::Ok, Self::Error> {
|
|
59
|
-
Ok(value.into_value_with(self.ruby))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
fn serialize_u16(self, value: u16) -> Result<Self::Ok, Self::Error> {
|
|
63
|
-
Ok(value.into_value_with(self.ruby))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fn serialize_u32(self, value: u32) -> Result<Self::Ok, Self::Error> {
|
|
67
|
-
Ok(value.into_value_with(self.ruby))
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
fn serialize_u64(self, value: u64) -> Result<Self::Ok, Self::Error> {
|
|
71
|
-
Ok(value.into_value_with(self.ruby))
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
fn serialize_u128(self, value: u128) -> Result<Self::Ok, Self::Error> {
|
|
75
|
-
Ok(value.into_value_with(self.ruby))
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
fn serialize_f32(self, value: f32) -> Result<Self::Ok, Self::Error> {
|
|
79
|
-
Ok(value.into_value_with(self.ruby))
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fn serialize_f64(self, value: f64) -> Result<Self::Ok, Self::Error> {
|
|
83
|
-
Ok(value.into_value_with(self.ruby))
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
fn serialize_char(self, value: char) -> Result<Self::Ok, Self::Error> {
|
|
87
|
-
Ok(value.into_value_with(self.ruby))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
fn serialize_str(self, value: &str) -> Result<Self::Ok, Self::Error> {
|
|
91
|
-
Ok(value.into_value_with(self.ruby))
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
fn serialize_bytes(self, value: &[u8]) -> Result<Self::Ok, Self::Error> {
|
|
95
|
-
Ok(self.ruby.str_from_slice(value).into_value_with(self.ruby))
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
|
|
99
|
-
Ok(().into_value_with(self.ruby))
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
fn serialize_some<Value>(self, value: &Value) -> Result<Self::Ok, Self::Error>
|
|
103
|
-
where
|
|
104
|
-
Value: Serialize + ?Sized,
|
|
105
|
-
{
|
|
106
|
-
value.serialize(self)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
|
|
110
|
-
Ok(().into_value_with(self.ruby))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
|
|
114
|
-
Ok(().into_value_with(self.ruby))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
fn serialize_unit_variant(
|
|
118
|
-
self,
|
|
119
|
-
_name: &'static str,
|
|
120
|
-
_index: u32,
|
|
121
|
-
variant: &'static str,
|
|
122
|
-
) -> Result<Self::Ok, Self::Error> {
|
|
123
|
-
Ok(variant.into_value_with(self.ruby))
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
fn serialize_newtype_struct<Value>(
|
|
127
|
-
self,
|
|
128
|
-
_name: &'static str,
|
|
129
|
-
value: &Value,
|
|
130
|
-
) -> Result<Self::Ok, Self::Error>
|
|
131
|
-
where
|
|
132
|
-
Value: Serialize + ?Sized,
|
|
133
|
-
{
|
|
134
|
-
value.serialize(self)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
fn serialize_newtype_variant<Value>(
|
|
138
|
-
self,
|
|
139
|
-
_name: &'static str,
|
|
140
|
-
_index: u32,
|
|
141
|
-
variant: &'static str,
|
|
142
|
-
value: &Value,
|
|
143
|
-
) -> Result<Self::Ok, Self::Error>
|
|
144
|
-
where
|
|
145
|
-
Value: Serialize + ?Sized,
|
|
146
|
-
{
|
|
147
|
-
nest(self.ruby, variant, value.serialize(self)?)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
|
|
151
|
-
Ok(SeqSerializer::new(
|
|
152
|
-
self.ruby,
|
|
153
|
-
self.ruby.ary_new_capa(len.unwrap_or(0)),
|
|
154
|
-
))
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, Self::Error> {
|
|
158
|
-
self.serialize_seq(Some(len))
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
fn serialize_tuple_struct(
|
|
162
|
-
self,
|
|
163
|
-
_name: &'static str,
|
|
164
|
-
len: usize,
|
|
165
|
-
) -> Result<Self::SerializeTupleStruct, Self::Error> {
|
|
166
|
-
self.serialize_seq(Some(len))
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
fn serialize_tuple_variant(
|
|
170
|
-
self,
|
|
171
|
-
_name: &'static str,
|
|
172
|
-
_index: u32,
|
|
173
|
-
variant: &'static str,
|
|
174
|
-
len: usize,
|
|
175
|
-
) -> Result<Self::SerializeTupleVariant, Self::Error> {
|
|
176
|
-
Ok(TupleVariantSerializer::new(
|
|
177
|
-
self.ruby,
|
|
178
|
-
variant,
|
|
179
|
-
self.ruby.ary_new_capa(len),
|
|
180
|
-
))
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
|
|
184
|
-
Ok(MapSerializer::new(
|
|
185
|
-
self.ruby,
|
|
186
|
-
hash_with_capacity(self.ruby, len.unwrap_or(0)),
|
|
187
|
-
))
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
fn serialize_struct(
|
|
191
|
-
self,
|
|
192
|
-
name: &'static str,
|
|
193
|
-
len: usize,
|
|
194
|
-
) -> Result<Self::SerializeStruct, Self::Error> {
|
|
195
|
-
Ok(StructSerializer::new(self.ruby, name, len))
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
fn serialize_struct_variant(
|
|
199
|
-
self,
|
|
200
|
-
_name: &'static str,
|
|
201
|
-
_index: u32,
|
|
202
|
-
variant: &'static str,
|
|
203
|
-
len: usize,
|
|
204
|
-
) -> Result<Self::SerializeStructVariant, Self::Error> {
|
|
205
|
-
Ok(StructVariantSerializer::new(
|
|
206
|
-
self.ruby,
|
|
207
|
-
variant,
|
|
208
|
-
hash_with_capacity(self.ruby, len),
|
|
209
|
-
))
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
pub(super) fn hash_with_capacity(ruby: &Ruby, capacity: usize) -> RHash {
|
|
214
|
-
// Magnus passes the capacity to Ruby as a C long, which can be narrower than usize.
|
|
215
|
-
if c_long::try_from(capacity).is_ok() {
|
|
216
|
-
ruby.hash_new_capa(capacity)
|
|
217
|
-
} else {
|
|
218
|
-
ruby.hash_new()
|
|
219
|
-
}
|
|
220
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
use super::{Serializer, enums::nest};
|
|
2
|
-
use crate::error::Error;
|
|
3
|
-
use magnus::{RHash, Ruby, Value};
|
|
4
|
-
use serde::{Serialize, ser::SerializeStructVariant};
|
|
5
|
-
|
|
6
|
-
pub(super) struct StructVariantSerializer<'r> {
|
|
7
|
-
ruby: &'r Ruby,
|
|
8
|
-
variant: &'static str,
|
|
9
|
-
hash: RHash,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
impl<'r> StructVariantSerializer<'r> {
|
|
13
|
-
pub fn new(ruby: &'r Ruby, variant: &'static str, hash: RHash) -> StructVariantSerializer<'r> {
|
|
14
|
-
StructVariantSerializer {
|
|
15
|
-
ruby,
|
|
16
|
-
variant,
|
|
17
|
-
hash,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
impl<'r> SerializeStructVariant for StructVariantSerializer<'r> {
|
|
23
|
-
type Ok = Value;
|
|
24
|
-
type Error = Error;
|
|
25
|
-
|
|
26
|
-
fn serialize_field<Value>(
|
|
27
|
-
&mut self,
|
|
28
|
-
name: &'static str,
|
|
29
|
-
value: &Value,
|
|
30
|
-
) -> Result<(), Self::Error>
|
|
31
|
-
where
|
|
32
|
-
Value: Serialize + ?Sized,
|
|
33
|
-
{
|
|
34
|
-
self.hash
|
|
35
|
-
.aset(
|
|
36
|
-
self.ruby.to_symbol(name),
|
|
37
|
-
value.serialize(Serializer::new(self.ruby))?,
|
|
38
|
-
)
|
|
39
|
-
.map_err(Into::into)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
fn end(self) -> Result<Self::Ok, Self::Error> {
|
|
43
|
-
nest(self.ruby, self.variant, self.hash)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
use super::{Serializer, enums::nest};
|
|
2
|
-
use crate::error::Error;
|
|
3
|
-
use magnus::{RArray, Ruby, Value};
|
|
4
|
-
use serde::{Serialize, ser::SerializeTupleVariant};
|
|
5
|
-
|
|
6
|
-
pub(super) struct TupleVariantSerializer<'r> {
|
|
7
|
-
ruby: &'r Ruby,
|
|
8
|
-
variant: &'static str,
|
|
9
|
-
array: RArray,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
impl<'r> TupleVariantSerializer<'r> {
|
|
13
|
-
pub fn new(ruby: &'r Ruby, variant: &'static str, array: RArray) -> TupleVariantSerializer<'r> {
|
|
14
|
-
TupleVariantSerializer {
|
|
15
|
-
ruby,
|
|
16
|
-
variant,
|
|
17
|
-
array,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
impl<'r> SerializeTupleVariant for TupleVariantSerializer<'r> {
|
|
23
|
-
type Ok = Value;
|
|
24
|
-
type Error = Error;
|
|
25
|
-
|
|
26
|
-
fn serialize_field<Field>(&mut self, field: &Field) -> Result<(), Self::Error>
|
|
27
|
-
where
|
|
28
|
-
Field: Serialize + ?Sized,
|
|
29
|
-
{
|
|
30
|
-
self.array
|
|
31
|
-
.push(field.serialize(Serializer::new(self.ruby))?)
|
|
32
|
-
.map_err(Into::into)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
fn end(self) -> Result<Self::Ok, self::Error> {
|
|
36
|
-
nest(self.ruby, self.variant, self.array)
|
|
37
|
-
}
|
|
38
|
-
}
|