Skip to content

refactor: deduplicate browser impersonation, add H2 window update fingerprinting, clean up Python response bindings#146

Merged
deedy5 merged 7 commits into
mainfrom
dev
May 18, 2026
Merged

refactor: deduplicate browser impersonation, add H2 window update fingerprinting, clean up Python response bindings#146
deedy5 merged 7 commits into
mainfrom
dev

Conversation

@deedy5

@deedy5 deedy5 commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary:

Browser Impersonation (primp, primp-python)

  • Deduplicated emulator construction across Chrome/Edge/Firefox/Opera/Safari using shared Arc<OnceLock> helpers
  • Added Chrome 147-148, Edge 147-148, Opera 130-131, Safari 18.6 profiles
  • Cached base header sets per browser to reduce per-request allocation
  • Gated impersonation-only code behind cfg(feature = "impersonate")

HTTP/2 Fingerprinting (primp-h2, primp-hyper, primp-reqwest)

  • Added initial_stream_window_size_increment to h2 Builder for browser-accurate WINDOW_UPDATE behavior (Firefox sends +12451840 on first stream)
  • Fixed connection-level WU frame ordering (buffered before HEADERS)
  • Exposed via ClientBuilder::http2_initial_stream_window_size_increment()

Python Bindings (primp-python)

  • Extracted shared sync/async response logic into response_shared.rs (~300 lines eliminated)
  • Fixed Bound::as_bytes vs Py::as_bytes(py) GIL signature
  • Used Python::attach for json_async (PyO3 0.28 API)
  • Removed duplicate IndexMapSSR type alias
  • Started tracking Cargo.lock for reproducible CI builds

Housekeeping

  • Fixed clippy::let_unit_value in h2 streams
  • Fixed mixed_attributes_style and io::Error::other lints across workspace
  • Proper #[cfg(feature = "http2")] gating on http2_headers_order init

deedy5 added 7 commits May 18, 2026 19:28
…nd enable h2 unstable feature

- primp-hyper: enable h2's 'unstable' feature for initial_stream_id()
- primp-rustls: gate GREASE constants, imports, and variables used only with impersonate
- primp-tokio-rustls: fix clippy io_other_error lint in test
- Add Chrome 147/148, Edge 147/148, Opera 130/131 impersonation profiles
- Add shared impersonation helpers (constants, os_platform, header orders)
- Switch BrowserSettings.browser_emulator to Arc<BrowserEmulator>
- Replace per-request emulator construction with OnceLock-cached Arc<BrowserEmulator>
- Consolidate duplicated settings into shared static data functions
- Optimize Chrome, Edge, Opera, Safari, and Firefox impersonation modules
- Fix clippy warning for redundant closure in safari_emulator
…upport

- Add initial_stream_window_increment field to Http2Data and stream state
- Flush initial stream WINDOW_UPDATE to wire before poll returns
- Propagate through primp-h2, primp-hyper, primp-hyper-util, primp-reqwest
- Fix sec-fetch-user position in all header order functions (before sec-fetch-dest)
- Remove cache-control from Chrome/Edge profiles (Opera-only header)
- Add priority header to all modern browser profiles
- Rename header_order_upgrade_first to header_order_upgrade_first_sec_chua_last
- Move sec-ch-ua block after sec-fetch-* for Chrome 148+ and Edge 146+
- Fix Sec-CH-UA grease brand names using correct grease_chars modulo 11
- Fix Sec-CH-UA grease versions using correct greased_versions modulo 3
- Fix Sec-CH-UA brand permutation order using seed % 6 lookup table
- Align all Chrome, Edge, and Opera Sec-CH-UA with Chromium GenerateBrandVersionList
…space

primp-python:
  - Extract duplicate sync/async response body/text/json/headers/cookies
    logic into response_shared.rs (~300 lines eliminated)
  - Fix Bound<PyBytes>::as_bytes vs Py<PyBytes>::as_bytes(py) mismatch
  - Use Python::attach for json_async GIL acquisition (PyO3 0.28 API)
  - Remove duplicate IndexMapSSR type alias in traits.rs
  - Track Cargo.lock (workspace with app crates needs reproducible builds)

primp-reqwest:
  - Gate http2_headers_order: None init with #[cfg(feature = "http2")]

primp-h2:
  - Fix clippy::let_unit_value on inc_connection_window() call

clippy fixes:
  - io::Error::new(ErrorKind::Other) -> io::Error::other()
  - Mixed inner/outer module attributes
@deedy5
deedy5 merged commit 7a2721f into main May 18, 2026
38 checks passed
@deedy5
deedy5 deleted the dev branch May 18, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant