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
20 changes: 2 additions & 18 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ 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_magnus = "0.11.0"
serde_json = { version = "1.0.150", features = [
"arbitrary_precision",
"preserve_order",
] }
indexmap = { version = "2.14.0", features = ["serde"] }
cookie = "0.18.1"
bytes = "1.12.1"
Expand All @@ -42,6 +45,9 @@ http = "1.4.1"
http-body-util = "0.1.3"
futures-util = { version = "0.3.32", default-features = false }

[dev-dependencies]
magnus = { version = "0.8.2", features = ["embed"] }

[build-dependencies]
rb-sys-env = "0.2.2"

Expand Down
27 changes: 18 additions & 9 deletions lib/wreq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ module Wreq
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.request(method, url, **options)
end

Expand Down Expand Up @@ -79,9 +80,10 @@ def self.request(method, url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.get(url, **options)
end

Expand Down Expand Up @@ -110,9 +112,10 @@ def self.get(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.head(url, **options)
end

Expand Down Expand Up @@ -141,9 +144,10 @@ def self.head(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.post(url, **options)
end

Expand Down Expand Up @@ -172,9 +176,10 @@ def self.post(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.put(url, **options)
end

Expand Down Expand Up @@ -203,9 +208,10 @@ def self.put(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.delete(url, **options)
end

Expand Down Expand Up @@ -234,9 +240,10 @@ def self.delete(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.options(url, **options)
end

Expand Down Expand Up @@ -265,9 +272,10 @@ def self.options(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.trace(url, **options)
end

Expand Down Expand Up @@ -296,9 +304,10 @@ def self.trace(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def self.patch(url, **options)
end
end
Expand Down
27 changes: 18 additions & 9 deletions lib/wreq_ruby/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ def self.new(**options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def request(method, url, **options)
end

Expand Down Expand Up @@ -291,9 +292,10 @@ def request(method, url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def get(url, **options)
end

Expand Down Expand Up @@ -322,9 +324,10 @@ def get(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def head(url, **options)
end

Expand Down Expand Up @@ -353,9 +356,10 @@ def head(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def post(url, **options)
end

Expand Down Expand Up @@ -384,9 +388,10 @@ def post(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def put(url, **options)
end

Expand Down Expand Up @@ -415,9 +420,10 @@ def put(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def delete(url, **options)
end

Expand Down Expand Up @@ -446,9 +452,10 @@ def delete(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def options(url, **options)
end

Expand Down Expand Up @@ -477,9 +484,10 @@ def options(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def trace(url, **options)
end

Expand Down Expand Up @@ -508,9 +516,10 @@ def trace(url, **options)
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
# @param version [Wreq::Version, nil] HTTP version to use
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
# @param json [Object, nil] JSON body (will be serialized)
# @param json [Object, nil] JSON body; preserves arbitrary-precision Integer values
# @param body [String, Wreq::BodySender, nil] Request body bytes or streaming body sender
# @return [Wreq::Response] HTTP response
# @raise [Wreq::BuilderError] if json cannot be serialized before network I/O
def patch(url, **options)
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/wreq_ruby/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def text(default_encoding = "UTF-8")

# Parse the response body as JSON.
#
# Integral JSON numbers are returned as arbitrary-precision Ruby Integer
# values. Fractional and exponent-form numbers are returned as Float values.
#
# @return [Object] Parsed JSON (Hash, Array, String, Integer, Float, Boolean, nil)
# @raise [Wreq::DecodingError] if body is not valid JSON
# @example
Expand Down
6 changes: 6 additions & 0 deletions script/build_windows_gnu.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function Invoke-Step {
)

Write-Host "==> $Name"
# Native command failures do not honor ErrorActionPreference in Windows PowerShell.
$global:LASTEXITCODE = 0
& $Command
if ($LASTEXITCODE -ne 0) {
throw "$Name failed with exit code $LASTEXITCODE."
}
}

function Get-MissingUcrtTools {
Expand Down Expand Up @@ -122,6 +127,7 @@ Invoke-Step "Check MSYS2 UCRT build tools" {
$stillMissing = @(Get-MissingUcrtTools)
if ($stillMissing.Count -eq 0) {
Write-Warning "pacman returned exit code $LASTEXITCODE, but all required tools are present; continuing."
$global:LASTEXITCODE = 0
return
}

Expand Down
1 change: 1 addition & 0 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! ABI boundaries, or OS APIs used by the Rust extension. Normal HTTP client
//! behavior should stay in the client/runtime modules so platform workarounds
//! do not leak into the rest of the binding.
#![allow(unsafe_code)]

#[cfg(all(target_os = "windows", target_env = "gnu"))]
mod windows_gnu {
Expand Down
5 changes: 3 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pub mod resp;

use std::{net::IpAddr, time::Duration};

use ::serde::Deserialize;
use magnus::{
Module, Object, RHash, RModule, Ruby, TryConvert, Value, function, method, typed_data::Obj,
};
use serde::Deserialize;
use wreq::Proxy;

use crate::{
Expand All @@ -21,6 +21,7 @@ use crate::{
gvl,
header::{Headers, OrigHeaders, UserAgent},
http::Method,
serde,
};

/// A builder for `Client`.
Expand Down Expand Up @@ -131,7 +132,7 @@ impl Builder {
return Ok(Default::default());
};

let mut builder: Self = serde_magnus::deserialize(ruby, hash)?;
let mut builder: Self = serde::deserialize_ruby(ruby, hash)?;

if let Some(v) = hash.get(ruby.to_symbol(stringify!(emulation))) {
builder.emulation = Some((*Obj::<Emulation>::try_convert(v)?).clone());
Expand Down
Loading
Loading