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
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ wreq = { version = "6.0.0-rc", features = [
] }
wreq-util = { version = "3.0.0-rc", features = ["emulation-compression"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_ignored = "0.1.14"
serde_json = { version = "1.0.150", features = [
"arbitrary_precision",
"preserve_order",
] }
serde_path_to_error = "0.1.20"
indexmap = { version = "2.14.0", features = ["serde"] }
cookie = "0.18.1"
bytes = "1.12.1"
Expand Down
123 changes: 69 additions & 54 deletions lib/wreq.rb

Large diffs are not rendered by default.

152 changes: 88 additions & 64 deletions lib/wreq_ruby/client.rb

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions lib/wreq_ruby/emulate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,28 @@ def to_s
#
# @param profile [Wreq::Profile, nil] Fingerprint profile to emulate
# @param platform [Wreq::Platform, nil] Operating system platform to emulate
# @param http2 [Boolean] Whether HTTP/2 support is enabled
# @param headers [Boolean] Whether default emulation headers are enabled
# @param http2 [Boolean, nil] Whether HTTP/2 emulation is enabled; defaults
# to true when omitted or nil
# @param headers [Boolean, nil] Whether default emulation headers are enabled;
# defaults to true when omitted or nil
# @return [Wreq::Emulation] Configured emulation settings
# @raise [ArgumentError] if an option is unknown or extra arguments are given
# @raise [TypeError] if the option argument is not a Hash or a value has the
# wrong Ruby type
class Emulation
# Native fields and methods are set by the extension.
# This stub is for documentation only.
unless method_defined?(:new)
# @param profile [Wreq::Profile, nil] Fingerprint profile to emulate
# @param platform [Wreq::Platform, nil] Operating system platform to emulate
# @param http2 [Boolean] Whether HTTP/2 support is enabled
# @param headers [Boolean] Whether default emulation headers are enabled
# @param http2 [Boolean, nil] Whether HTTP/2 emulation is enabled; defaults
# to true when omitted or nil
# @param headers [Boolean, nil] Whether default emulation headers are enabled;
# defaults to true when omitted or nil
# @return [Wreq::Emulation] Configured emulation settings
def self.new(profile: nil, platform: nil, http2: true, headers: true)
# @raise [ArgumentError] if an option is unknown or extra arguments are given
# @raise [TypeError] if an option or value has the wrong Ruby type
def self.new(**options)
end
end
end
Expand Down
12 changes: 5 additions & 7 deletions lib/wreq_ruby/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class StatusError < StandardError; end
#
# @example
# begin
# client = Wreq::Client.new(max_redirects: 3)
# client = Wreq::Client.new(allow_redirects: true, max_redirects: 3)
# client.get("https://httpbin.io/redirect/10")
# rescue Wreq::RedirectError => e
# puts "Too many redirects: #{e.message}"
Expand Down Expand Up @@ -139,16 +139,14 @@ class DecodingError < StandardError; end

# Configuration and builder errors

# Client configuration is invalid.
# A native client or request configuration could not be built.
#
# Raised when the client is configured with invalid options.
# Raised when validated Ruby options cannot be represented by the native
# builder or request body.
#
# @example
# begin
# client = Wreq::Client.new(
# proxy: "invalid://proxy",
# timeout: -1
# )
# client = Wreq::Client.new(proxy: "invalid://")
# rescue Wreq::BuilderError => e
# puts "Invalid configuration: #{e.message}"
# end
Expand Down
21 changes: 21 additions & 0 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
//! do not leak into the rest of the binding.
#![allow(unsafe_code)]

/// Whether the native client exposes TCP user-timeout configuration.
pub(crate) const SUPPORTS_TCP_USER_TIMEOUT: bool = cfg!(any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux"
));

/// Whether the native client exposes network-interface binding.
pub(crate) const SUPPORTS_INTERFACE: bool = cfg!(any(
target_os = "android",
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "solaris",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
));

#[cfg(all(target_os = "windows", target_env = "gnu"))]
mod windows_gnu {
//! Windows GNU support.
Expand Down
Loading