wreq 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15ad9f6cc6c41b23c065d2118942ce008260dd0b0ec0124e03d5d72379ed9dda
4
- data.tar.gz: ef0c61872bffe6dc3e3e7e820d1d774f944d129a5e486e1c8fe50c53d06b4c5d
3
+ metadata.gz: 847301c3eef022dc8dbdc25f84308f03ef73ac06f366caea11ecad0df51c8342
4
+ data.tar.gz: 6ec2ed9471e605f58546a9deeba976ccc4984a1b3c2372e3f9d2e85fdd3d3f94
5
5
  SHA512:
6
- metadata.gz: a2c870dd5fedc1dfd0c72de4b1567b63f9a44ce361a7f6e47a57bfe751ddf1c083a4828542f778236ce1bc2bc529e7b85df19ef33c742580a695df33ac114cd2
7
- data.tar.gz: b2616fcfc85af1ac603ea330ca6f2c697aa81049d36471df4619327ad0d549af974078f14d4d3f76aee0e581ac8f8fed6d711778d64c8b82fad8c038cec3f14b
6
+ metadata.gz: 5bbebe9ab0ad0119019d95d15c37266fff1d22832f0beaf8f576ceb461bcb7129da8c617c17dbac0c1b918f5cf992b52c1d14ea140b9753a573dde3c9ee959a2
7
+ data.tar.gz: 7baa2818b2a41af307f1152c4a4608ab7b3d2d3d921b29e50f4587637838318808b0153d80fdb9f4761a3454d42c3f51101d09c06f679f5583d8c733f39b73b5
data/Cargo.lock CHANGED
@@ -85,9 +85,9 @@ dependencies = [
85
85
 
86
86
  [[package]]
87
87
  name = "bitflags"
88
- version = "2.12.1"
88
+ version = "2.13.0"
89
89
  source = "registry+https://github.com/rust-lang/crates.io-index"
90
- checksum = "84d7ced0ae9557296835c32bf1b1e02b44c746701f898460fb000d7eaa84f00a"
90
+ checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
91
91
 
92
92
  [[package]]
93
93
  name = "brotli"
@@ -444,9 +444,9 @@ dependencies = [
444
444
 
445
445
  [[package]]
446
446
  name = "http"
447
- version = "1.4.1"
447
+ version = "1.4.2"
448
448
  source = "registry+https://github.com/rust-lang/crates.io-index"
449
- checksum = "8be7462df143984c4598a256ef469b251d7d7f9e271135073e78fc535414f3d0"
449
+ checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425"
450
450
  dependencies = [
451
451
  "bytes",
452
452
  "itoa",
@@ -477,9 +477,9 @@ dependencies = [
477
477
 
478
478
  [[package]]
479
479
  name = "http2"
480
- version = "0.5.17"
480
+ version = "0.5.18"
481
481
  source = "registry+https://github.com/rust-lang/crates.io-index"
482
- checksum = "569ef7a780e853c4e1768f58a3c8168193b82cdcbab66638a0b1c6583ec5995e"
482
+ checksum = "9d8c910a959d6fd27dd6f8fdb26509ac0f6561465cc8c5f875d45a203ab97911"
483
483
  dependencies = [
484
484
  "atomic-waker",
485
485
  "bytes",
@@ -902,9 +902,9 @@ dependencies = [
902
902
 
903
903
  [[package]]
904
904
  name = "regex"
905
- version = "1.12.3"
905
+ version = "1.12.4"
906
906
  source = "registry+https://github.com/rust-lang/crates.io-index"
907
- checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
907
+ checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba"
908
908
  dependencies = [
909
909
  "aho-corasick",
910
910
  "memchr",
@@ -925,9 +925,9 @@ dependencies = [
925
925
 
926
926
  [[package]]
927
927
  name = "regex-syntax"
928
- version = "0.8.10"
928
+ version = "0.8.11"
929
929
  source = "registry+https://github.com/rust-lang/crates.io-index"
930
- checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
930
+ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
931
931
 
932
932
  [[package]]
933
933
  name = "rustc-hash"
@@ -1559,7 +1559,7 @@ dependencies = [
1559
1559
 
1560
1560
  [[package]]
1561
1561
  name = "wreq-ruby"
1562
- version = "1.2.1"
1562
+ version = "1.2.2"
1563
1563
  dependencies = [
1564
1564
  "arc-swap",
1565
1565
  "bytes",
data/Cargo.toml CHANGED
@@ -6,7 +6,7 @@ homepage = "https://github.com/SearchApi/wreq-ruby"
6
6
  repository = "https://github.com/SearchApi/wreq-ruby"
7
7
  edition = "2024"
8
8
  rust-version = "1.85"
9
- version = "1.2.1"
9
+ version = "1.2.2"
10
10
 
11
11
  [lib]
12
12
  crate-type = ["cdylib"]
data/src/client.rs CHANGED
@@ -10,7 +10,7 @@ use magnus::{
10
10
  Module, Object, RHash, RModule, Ruby, TryConvert, Value, function, method, typed_data::Obj,
11
11
  };
12
12
  use serde::Deserialize;
13
- use wreq::{Proxy, header::HeaderValue};
13
+ use wreq::Proxy;
14
14
 
15
15
  use crate::{
16
16
  client::{req::execute_request, resp::Response},
@@ -19,7 +19,7 @@ use crate::{
19
19
  error::wreq_error_to_magnus,
20
20
  extractor::Extractor,
21
21
  gvl,
22
- header::{Headers, OrigHeaders},
22
+ header::{Headers, OrigHeaders, UserAgent},
23
23
  http::Method,
24
24
  };
25
25
 
@@ -31,7 +31,7 @@ struct Builder {
31
31
  emulation: Option<Emulation>,
32
32
  /// The user agent to use for the client.
33
33
  #[serde(skip)]
34
- user_agent: Option<HeaderValue>,
34
+ user_agent: Option<UserAgent>,
35
35
  /// The headers to use for the client.
36
36
  #[serde(skip)]
37
37
  headers: Option<Headers>,
@@ -136,6 +136,10 @@ impl Builder {
136
136
  builder.emulation = Some((*Obj::<Emulation>::try_convert(v)?).clone());
137
137
  }
138
138
 
139
+ if let Some(v) = hash.get(ruby.to_symbol(stringify!(user_agent))) {
140
+ builder.user_agent = Some(UserAgent::try_convert(v)?);
141
+ }
142
+
139
143
  if let Some(v) = hash.get(ruby.to_symbol(stringify!(headers))) {
140
144
  builder.headers = Some(Headers::try_convert(v)?);
141
145
  }
@@ -148,11 +152,6 @@ impl Builder {
148
152
  builder.cookie_provider = Some((*Obj::<Jar>::try_convert(v)?).clone());
149
153
  }
150
154
 
151
- if let Some(jar) = hash.get(ruby.to_symbol(stringify!(cookie_provider))) {
152
- builder.cookie_provider = Some((*Obj::<Jar>::try_convert(jar)?).clone());
153
- }
154
-
155
- builder.user_agent = Extractor::<HeaderValue>::try_convert(*keyword)?.into_inner();
156
155
  builder.proxy = Extractor::<Proxy>::try_convert(*keyword)?.into_inner();
157
156
 
158
157
  Ok(builder)
@@ -173,7 +172,7 @@ impl Client {
173
172
  apply_option!(set_if_some_inner, builder, params.emulation, emulation);
174
173
 
175
174
  // User agent options.
176
- apply_option!(set_if_some, builder, params.user_agent, user_agent);
175
+ apply_option!(set_if_some_inner, builder, params.user_agent, user_agent);
177
176
 
178
177
  // Headers options.
179
178
  apply_option!(
data/src/extractor.rs CHANGED
@@ -32,31 +32,6 @@ where
32
32
  }
33
33
  }
34
34
 
35
- // ===== impl Extractor<HeaderValue> =====
36
-
37
- impl ExtractorName for HeaderValue {
38
- const NAME: &str = "user_agent";
39
- }
40
-
41
- impl TryConvert for Extractor<HeaderValue> {
42
- fn try_convert(value: magnus::Value) -> Result<Self, magnus::Error> {
43
- let ruby = Ruby::get_with(value);
44
- let keyword = RHash::try_convert(value)?;
45
-
46
- if let Some(ruby_value) = keyword
47
- .get(ruby.to_symbol(HeaderValue::NAME))
48
- .and_then(RString::from_value)
49
- {
50
- return HeaderValue::from_maybe_shared(ruby_value.to_bytes())
51
- .map(Some)
52
- .map(Extractor)
53
- .map_err(header_value_error_to_magnus);
54
- }
55
-
56
- Ok(Extractor(None))
57
- }
58
- }
59
-
60
35
  // ===== impl Extractor<HeaderMap> =====
61
36
 
62
37
  impl ExtractorName for HeaderMap {
data/src/header.rs CHANGED
@@ -15,6 +15,9 @@ use crate::error::{
15
15
  header_name_error_to_magnus, header_value_error_to_magnus, type_value_error_to_magnus,
16
16
  };
17
17
 
18
+ /// A wrapper for the User-Agent header value.
19
+ pub struct UserAgent(pub HeaderValue);
20
+
18
21
  /// HTTP headers collection with read and write operations.
19
22
  ///
20
23
  /// This class wraps HTTP headers and provides convenient methods for
@@ -31,6 +34,17 @@ struct HeaderIter {
31
34
  next_name: Option<HeaderName>,
32
35
  }
33
36
 
37
+ // ===== impl UserAgent =====
38
+
39
+ impl TryConvert for UserAgent {
40
+ fn try_convert(value: Value) -> Result<Self, Error> {
41
+ let s = RString::try_convert(value)?;
42
+ let header_value =
43
+ HeaderValue::from_maybe_shared(s.to_bytes()).map_err(header_value_error_to_magnus)?;
44
+ Ok(Self(header_value))
45
+ }
46
+ }
47
+
34
48
  // ===== impl Headers =====
35
49
 
36
50
  impl Headers {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SearchApi