CloakedReq (cloaked_req v0.5.1)

Copy Markdown View Source

Req adapter powered by Rust wreq.

Summary

Functions

Attaches CloakedReq adapter behavior to an existing Req.Request.

Sets the impersonation profile and configures the CloakedReq Req adapter.

Functions

attach(request, options \\ [])

@spec attach(
  Req.Request.t(),
  keyword()
) :: Req.Request.t()

Attaches CloakedReq adapter behavior to an existing Req.Request.

Supported adapter-relevant options:

  • :cookie_jar - %CloakedReq.CookieJar{} for automatic cookie persistence
  • :connect_options - Req transport options for :timeout, :proxy, and :proxy_headers
  • :impersonate - profile atom (e.g. :chrome_136, :"safari_17.4.1")
  • :insecure_skip_verify - boolean
  • :local_address - outbound source IP as string, IPv4 tuple, or IPv6 tuple
  • :max_body_size - positive integer or :unlimited (default: 10 MB); caps both the request body (rejected before sending if larger) and the response body (truncated to an error once it exceeds the limit)
  • :pool - %CloakedReq.Pool{} built with CloakedReq.Pool.new/1, routing the request through a dedicated, isolated client and connection pool. The pool's client governs the impersonation profile, TLS verification, and connect timeout, so per-request :impersonate, :insecure_skip_verify, and the :connect_options connect timeout are ignored (still validated if given). The :connect_options proxy, :local_address, headers, body, :cookie_jar, and :receive_timeout still apply per request.

Examples

iex> req = Req.new(url: "https://example.com") |> CloakedReq.attach(impersonate: :chrome_136)
iex> is_function(req.adapter, 1)
true
iex> Req.Request.get_option(req, :impersonate)
:chrome_136

impersonate(request, profile)

@spec impersonate(Req.Request.t(), atom()) :: Req.Request.t()

Sets the impersonation profile and configures the CloakedReq Req adapter.

Examples

iex> req = Req.new(url: "https://example.com") |> CloakedReq.impersonate(:chrome_136)
iex> Req.Request.get_option(req, :impersonate)
:chrome_136
iex> is_function(req.adapter, 1)
true