Skip to content

Commit c33b4b4

Browse files
authored
build(deps): bump wreq version to latest (#562)
* build(deps): bump wreq version to latest * fix static link libstdc++.a * static link libgcc.a
1 parent 2eca676 commit c33b4b4

27 files changed

Lines changed: 768 additions & 455 deletions

.github/musl_build.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
if [ -z "$1" ]; then
46
echo "Usage: $0 <target> [maturin_args]"
57
exit 1
@@ -9,8 +11,15 @@ TARGET=$1
911
ARGS=$2
1012

1113
IMAGE="ghcr.io/0x676e67/rust-musl-cross"
12-
VOLUME_MAPPING="-v $(pwd):/home/rust/src"
14+
VOLUME_MAPPING=("-v" "$(pwd):/home/rust/src")
1315
MATURIN_CMD="maturin build --release --out dist $ARGS"
16+
EXTRA_ENV=()
17+
18+
for var in BORING_BSSL_RUST_CPPLIB MATURIN_VERSION CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS; do
19+
if [ -n "${!var}" ]; then
20+
EXTRA_ENV+=("-e" "$var=${!var}")
21+
fi
22+
done
1423

1524
case $TARGET in
1625
x86_64-unknown-linux-musl | \
@@ -26,6 +35,6 @@ esac
2635

2736
echo "Building for $TARGET..."
2837
docker pull $IMAGE:$TARGET
29-
docker run --rm $VOLUME_MAPPING $IMAGE:$TARGET /bin/bash -c "$MATURIN_CMD"
38+
docker run --rm "${VOLUME_MAPPING[@]}" "${EXTRA_ENV[@]}" $IMAGE:$TARGET /bin/bash -c "$MATURIN_CMD"
3039

3140
echo "Build completed for target: $TARGET"

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ jobs:
105105
custom_env:
106106
CC: i686-linux-gnu-gcc
107107
CXX: i686-linux-gnu-g++
108+
CFLAGS: -msse2
109+
CXXFLAGS: -msse2
110+
CFLAGS_i686_unknown_linux_gnu: -msse2
111+
CXXFLAGS_i686_unknown_linux_gnu: -msse2
108112
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-g++
109113
- runner: ubuntu-latest
110114
target: aarch64
@@ -127,10 +131,6 @@ jobs:
127131
- uses: actions/setup-python@v6
128132
with:
129133
python-version: 3.x
130-
- name: Install LLVM and Clang
131-
uses: KyleMayes/install-llvm-action@v2
132-
with:
133-
version: "13.0"
134134
- name: Install target-specific APT dependencies
135135
if: "matrix.platform.apt_packages != ''"
136136
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.platform.apt_packages }}
@@ -177,9 +177,16 @@ jobs:
177177
steps:
178178
- uses: actions/checkout@v6
179179
- name: Build wheels
180-
run: bash .github/musl_build.sh ${{ matrix.platform.target }} "${{ matrix.build_type.maturin_args }}" --features "${{ matrix.platform.allocator }}"
181180
env:
182181
MATURIN_VERSION: ${{ env.MATURIN_VERSION }}
182+
BORING_BSSL_RUST_CPPLIB: static=stdc++
183+
run: |
184+
export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-L native=/usr/local/musl/${{ matrix.platform.target }}/lib -L native=/usr/local/musl/lib/gcc/${{ matrix.platform.target }}/11.4.0 -C link-arg=-static-libgcc -l static=gcc"
185+
if [ "${{ matrix.platform.target }}" = "i686-unknown-linux-musl" ]; then
186+
export CFLAGS="${CFLAGS} -msse2"
187+
export CXXFLAGS="${CXXFLAGS} -msse2"
188+
fi
189+
bash .github/musl_build.sh ${{ matrix.platform.target }} "${{ matrix.build_type.maturin_args }}" --features "${{ matrix.platform.allocator }}"
183190
- name: Upload wheels
184191
uses: actions/upload-artifact@v7
185192
with:
@@ -242,10 +249,10 @@ jobs:
242249
- name: free-threaded
243250
maturin_args: "--interpreter 3.13t 3.14t"
244251
platform:
245-
- runner: macos-14
252+
- runner: macos-latest
246253
target: x86_64
247254
allocator: jemalloc
248-
- runner: macos-14
255+
- runner: macos-latest
249256
target: aarch64
250257
allocator: jemalloc
251258
steps:

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ wreq = { version = "6.0.0-rc.27", features = [
6565
"deflate",
6666
"zstd",
6767
"ws",
68+
"parking_lot",
6869
] }
69-
wreq-util = { version = "3.0.0-rc.10", features = ["emulation-rand", "emulation-compression"] }
70+
wreq-util = { version = "3.0.0-rc.10", features = ["emulation-compression"] }
7071
hickory-resolver = "0.25.2"
7172
cookie = "0.18"
7273
mimalloc = { version = "0.1.43", default-features = false, features = [
@@ -86,4 +87,5 @@ panic = "abort"
8687
strip = true
8788

8889
[patch.crates-io]
89-
wreq = { git = "https://github.com/0x676e67/wreq", rev = "240d84eab5eb4df8548933ee2c13337d86e1afe1" }
90+
wreq = { git = "https://github.com/0x676e67/wreq" }
91+
wreq-util = { git = "https://github.com/0x676e67/wreq-util" }

docs/mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ markdown_extensions:
8686
- pymdownx.details
8787
- attr_list
8888
- md_in_html
89-
- pymdownx.emoji
89+
- pymdownx.emoji:
90+
emoji_index: !!python/name:material.extensions.emoji.twemoji
91+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
9092
- pymdownx.tasklist
9193
- pymdownx.caret
9294
- pymdownx.mark

docs/source/getting-started/introduction.md

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,83 @@ Due to the complexity of **TLS** encryption and the widespread adoption of **HTT
5555

5656
**TLS** and **HTTP/2** fingerprints are often identical across various browser models because these underlying protocols evolve slower than browser release cycles. **100+ browser device emulation profiles** are maintained in **[wreq-python]**.
5757

58-
??? note "Available OS emulations"
59-
60-
| **OS** | **Description** |
61-
| ----------- | ------------------------------ |
62-
| **Windows** | Windows (any version) |
63-
| **MacOS** | macOS (any version) |
64-
| **Linux** | Linux (any distribution) |
65-
| **Android** | Android (mobile) |
66-
| **iOS** | iOS (iPhone/iPad) |
67-
68-
??? note "Available browser emulations"
69-
70-
| **Browser** | **Versions** |
71-
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72-
| **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145` |
73-
| **Safari** | `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos16_5`, `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari18`, `SafariIPad18`, `Safari18_2`, `SafariIos18_1_1`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos26`, `SafariIos26_2`, `SafariIPad26`, `SafariIPad26_2` |
74-
| **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147` |
75-
| **OkHttp** | `OkHttp3_9`, `OkHttp3_11`, `OkHttp3_13`, `OkHttp3_14`, `OkHttp4_9`, `OkHttp4_10`, `OkHttp4_12`, `OkHttp5` |
76-
| **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145` |
77-
| **Opera** | `Opera116`, `Opera117`, `Opera118`, `Opera119`
58+
???+ note "Available OS emulations"
59+
60+
<div class="grid cards" markdown>
61+
62+
- :fontawesome-brands-windows: **Windows**
63+
64+
---
65+
66+
Windows (any version)
67+
68+
- :fontawesome-brands-apple: **macOS**
69+
70+
---
71+
72+
macOS (any version)
73+
74+
- :fontawesome-brands-linux: **Linux**
75+
76+
---
77+
78+
Linux (any distribution)
79+
80+
- :fontawesome-brands-android: **Android**
81+
82+
---
83+
84+
Android (mobile)
85+
86+
- :fontawesome-brands-apple: **iOS**
87+
88+
---
89+
90+
iOS (iPhone / iPad)
91+
92+
</div>
93+
94+
???+ note "Available browser emulations"
95+
96+
<div class="grid cards" markdown>
97+
98+
- :fontawesome-brands-chrome: **Chrome**
99+
100+
---
101+
102+
`Chrome100` `Chrome101` `Chrome104` `Chrome105` `Chrome106` `Chrome107` `Chrome108` `Chrome109` `Chrome110` `Chrome114` `Chrome116` `Chrome117` `Chrome118` `Chrome119` `Chrome120` `Chrome123` `Chrome124` `Chrome126` `Chrome127` `Chrome128` `Chrome129` `Chrome130` `Chrome131` `Chrome132` `Chrome133` `Chrome134` `Chrome135` `Chrome136` `Chrome137` `Chrome138` `Chrome139` `Chrome140` `Chrome141` `Chrome142` `Chrome143` `Chrome144` `Chrome145` `Chrome146` `Chrome147`
103+
104+
- :fontawesome-brands-edge: **Edge**
105+
106+
---
107+
108+
`Edge101` `Edge122` `Edge127` `Edge131` `Edge134` `Edge135` `Edge136` `Edge137` `Edge138` `Edge139` `Edge140` `Edge141` `Edge142` `Edge143` `Edge144` `Edge145`
109+
110+
- :fontawesome-brands-firefox: **Firefox**
111+
112+
---
113+
114+
`Firefox109` `Firefox117` `Firefox128` `Firefox133` `Firefox135` `FirefoxPrivate135` `FirefoxAndroid135` `Firefox136` `FirefoxPrivate136` `Firefox139` `Firefox142` `Firefox143` `Firefox144` `Firefox145` `Firefox146` `Firefox147` `Firefox148` `Firefox149`
115+
116+
- :fontawesome-brands-safari: **Safari**
117+
118+
---
119+
120+
`SafariIos17_2` `SafariIos17_4_1` `SafariIos16_5` `Safari15_3` `Safari15_5` `Safari15_6_1` `Safari16` `Safari16_5` `Safari17_0` `Safari17_2_1` `Safari17_4_1` `Safari17_5` `Safari18` `SafariIPad18` `Safari18_2` `Safari18_3` `Safari18_3_1` `SafariIos18_1_1` `Safari18_5` `Safari26` `Safari26_1` `Safari26_2` `SafariIos26` `SafariIos26_2` `SafariIPad26` `SafariIpad26_2`
121+
122+
- :fontawesome-brands-opera: **Opera**
123+
124+
---
125+
126+
`Opera116` `Opera117` `Opera118` `Opera119` `Opera120` `Opera121` `Opera122` `Opera123` `Opera124` `Opera125` `Opera126` `Opera127` `Opera128` `Opera129` `Opera130`
127+
128+
- :material-web: **OkHttp**
129+
130+
---
131+
132+
`OkHttp3_9` `OkHttp3_11` `OkHttp3_13` `OkHttp3_14` `OkHttp4_9` `OkHttp4_10` `OkHttp4_12` `OkHttp5`
133+
134+
</div>
78135

79136

80137
## Performance

docs/source/guide/emulation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ if __name__ == "__main__":
3030
```python
3131
import asyncio
3232
from wreq import Client
33-
from wreq.emulation import Emulation, EmulationOS, EmulationOption
33+
from wreq.emulation import Emulation, Profile, Platform
3434

3535

3636
async def main():
3737
client = Client()
3838
resp = await client.get(
3939
"https://tls.peet.ws/api/all",
40-
emulation=EmulationOption(
41-
emulation=Emulation.Chrome134,
42-
emulation_os=EmulationOS.Android,
40+
emulation=Emulation(
41+
profile=Profile.Chrome134,
42+
platform=Platform.Android,
4343
),
4444
# Disable client default headers
4545
default_headers=False,

docs/source/guide/websocket.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import asyncio
1111
import datetime
1212
import wreq
13-
from wreq import Message, WebSocket
13+
from wreq import Message, WebSocket, Version
1414
from wreq import exceptions
1515

1616

@@ -95,11 +95,11 @@ async def recv_message(ws):
9595

9696

9797
async def main():
98-
# Connect to HTTP/2 WebSocket server with force_http2=True
98+
# Connect to HTTP/2 WebSocket server
9999
client = wreq.Client(verify=False)
100100
ws: WebSocket = await client.websocket(
101101
"wss://127.0.0.1:3000/ws",
102-
force_http2=True
102+
version=Version.HTTP_2
103103
)
104104
async with ws:
105105
print("Status Code: ", ws.status)

examples/emulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from wreq import Client, Response
3-
from wreq.emulation import Emulation, EmulationOS, EmulationOption
3+
from wreq.emulation import Emulation, Profile, Platform
44
from wreq.tls import TlsOptions, TlsVersion, AlpnProtocol
55
from wreq.http2 import Http2Options, PseudoId, PseudoOrder
66
from wreq.header import HeaderMap, OrigHeaderMap
@@ -49,9 +49,9 @@ async def request_chrome_android(client: Client):
4949
print("\n[Testing Chrome on Android Emulation]")
5050
resp = await client.get(
5151
"https://tls.peet.ws/api/all",
52-
emulation=EmulationOption(
53-
emulation=Emulation.Chrome134,
54-
emulation_os=EmulationOS.Android,
52+
emulation=Emulation(
53+
profile=Profile.Chrome134,
54+
platform=Platform.Android,
5555
),
5656
# Disable client default headers
5757
default_headers=False,

examples/http2_websocket.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import datetime
33
import signal
44
import wreq
5-
from wreq import Message, WebSocket
5+
from wreq import Message, WebSocket, Version
66
from wreq import exceptions
77

88

@@ -45,7 +45,9 @@ async def recv_message(ws):
4545

4646
async def main():
4747
client = wreq.Client(tls_verify=False)
48-
ws: WebSocket = await client.websocket("wss://127.0.0.1:3000/ws", force_http2=True)
48+
ws: WebSocket = await client.websocket(
49+
"wss://127.0.0.1:3000/ws", version=Version.HTTP_2
50+
)
4951
async with ws:
5052
print("Status Code: ", ws.status)
5153
print("Version: ", ws.version)

python/wreq/blocking.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,9 @@ def close(self) -> None:
114114
r"""
115115
Close the response.
116116
117-
**Current behavior:**
118-
119-
- When connection pooling is **disabled**: This method closes the network connection.
120-
- When connection pooling is **enabled**: This method closes the response, prevents further body reads,
121-
and returns the connection to the pool for reuse.
122-
123-
**Future changes:**
124-
125-
In future versions, this method will be changed to always close the network connection regardless of
126-
whether connection pooling is enabled or not.
127-
128-
**Recommendation:**
129-
130-
It is **not recommended** to manually call this method at present. Instead, use context managers
131-
(with statement) to properly manage response lifecycle. Wait for the improved implementation
132-
in future versions.
117+
This method closes the network connection regardless of whether connection pooling is
118+
enabled or not. It is recommended to use context managers (`with` statement) to properly
119+
manage response lifecycle instead of calling this method manually.
133120
"""
134121

135122
def __enter__(self) -> Any: ...

0 commit comments

Comments
 (0)