Skip to main content

Crate bimp_net

Crate bimp_net 

Source
Expand description

Browser-like HTTP transport backed by libcurl-impersonate.

bimp-net exposes a small Rust API around curl_easy_impersonate, making it possible to issue requests with browser-oriented TLS and HTTP fingerprints while still receiving responses through normal Rust http and hyper body types.

§Native dependency

This crate links to libcurl-impersonate. Local builds expect one of these files in /usr/local/lib:

  • libcurl-impersonate.dylib
  • libcurl-impersonate.so
  • libcurl-impersonate.a

docs.rs builds skip native linking so API documentation can render without the library installed.

§Collecting a response

use bimp_net::{Client, Config, RedirectPolicy};
use http::{Method, Request};

let client = Client::new(Config {
    impersonation_target: "chrome136".to_string(),
    redirect_policy: RedirectPolicy::Follow,
    ..Config::default()
});

let request = Request::builder()
    .method(Method::GET)
    .uri("https://example.com/")
    .body(None)?;
let response = client.send_collect(request)?;
println!("{} bytes from {}", response.body.len(), response.effective_url);

§Streaming a response

use bimp_net::{Client, Config};
use http::Request;
use http_body_util::{BodyExt, Empty};
use hyper::body::Bytes;

let client = Client::new(Config::default());
let request = Request::builder()
    .uri("https://example.com/")
    .body(Empty::<Bytes>::new())?;
let mut response = client.send(request).await?;
while let Some(frame) = response.body_mut().frame().await {
    if let Some(bytes) = frame?.data_ref() {
        println!("received {} bytes", bytes.len());
    }
}

Structs§

Body
Streaming response body returned by crate::Client::send.
Client
HTTP client that executes requests with libcurl-impersonate.
CollectedResponse
Fully collected response returned by crate::Client::send_collect.
Config
Configuration applied to every request sent by a crate::Client.

Enums§

Error
Error type returned by bimp-net operations.
RedirectPolicy
Redirect handling policy for a request.

Type Aliases§

Result
Result alias using Error as the default error type.