Struct ProfileEmulateLayer
pub struct ProfileEmulateLayer<P = Arc<UserAgentDatabase>> { /* private fields */ }std and ua only.Expand description
Select a captured profile and publish its immutable emulation context.
The selected identity follows the configured ProfileSelector, completed by a
UserAgent request extension or, with auto-detection, the request’s own
User-Agent header. When no profile of that identity can emulate the request,
ProfileSelectFallback decides whether a looser identity is tried; an auto-detected
User-Agent without any profile falls back to its browser family.
§Request flow
A profile holds the requests it captured per flow: the HTTP version, the method,
the RequestInitiator and the Sec-Fetch-Mode, Sec-Fetch-Dest,
Sec-Fetch-User and Sec-Fetch-Site values. A request without an initiator is
described by its Fetch metadata, so a capture with the same method and Fetch
metadata is its flow whatever initiated it; without either it is a top-level
navigation. A request without Sec-Fetch-* headers takes the capture’s.
A capture of the request’s own flow replays when the identity has one, and profiles holding one win over profiles that do not. Otherwise the closest capture replays. It always shares the request’s HTTP version and connection context, and a WebSocket handshake or CONNECT tunnel only stands in for another one. Among the rest, a capture that differs in a less significant field is closer; from most to least significant:
Sec-Fetch-ModeSec-Fetch-Dest- the method
Sec-Fetch-UserSec-Fetch-Site- the initiator
A RequestInitiator::Navigate link navigation thus replays a form submission
with the same Fetch metadata, and a stylesheet replays a navigation when no stylesheet was captured. Identity
fallback only applies when the identity has no capture to stand in at all, under any
HTTP version the connection may negotiate; the request draws for the negotiated one.
Without a caller TargetHttpVersion or ALPN, a secure TCP request offers the HTTP
versions the profile captured for that kind of request. Ordinary requests, CONNECT
tunnels and WebSocket handshakes each use their own captured versions.
A closest capture replays with the caller’s own request context, as those fields
describe the request rather than the browser. The caller’s Sec-Fetch-* fields
replace the captured ones, and so do its Accept, Priority and
Upgrade-Insecure-Requests when the Fetch mode or destination differ. A kept
field takes the captured field’s position, one the capture lacks is appended
after the captured fields, and a captured one the caller did not send is omitted. A caller without
Fetch metadata keeps the capture’s. An HTTP/3 :method captured for another
method is encoded natively, and a connection’s first HTTP/3 request drops the
captured initial QPACK insertions. Such a request lists
LoweredProfileItem::NearestFlow in its ProfilePreservationReport, and its
RequestSelection records the FlowMatch.
§Caller identity
A request keeps parts of its own identity with the PreserveHeaderUserAgent
and PreserveClientHints extensions, or a UserAgent extension whose HTTP
or TLS agent is Preserve. Each kept part is listed in the request’s
ProfilePreservationReport and never fails the request.
Implementations§
§impl<P> ProfileEmulateLayer<P>
impl<P> ProfileEmulateLayer<P>
pub fn new(source: P) -> ProfileEmulateLayer<P>
pub fn with_selector(self, selector: ProfileSelector) -> ProfileEmulateLayer<P>
pub fn with_selector(self, selector: ProfileSelector) -> ProfileEmulateLayer<P>
Restrict captured profile selection.
pub fn set_selector(
&mut self,
selector: ProfileSelector,
) -> &mut ProfileEmulateLayer<P>
pub fn set_selector( &mut self, selector: ProfileSelector, ) -> &mut ProfileEmulateLayer<P>
Restrict captured profile selection.
pub fn maybe_with_seed(
self,
seed: Option<ProfileSeed>,
) -> ProfileEmulateLayer<P>
pub fn maybe_with_seed( self, seed: Option<ProfileSeed>, ) -> ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn maybe_set_seed(
&mut self,
seed: Option<ProfileSeed>,
) -> &mut ProfileEmulateLayer<P>
pub fn maybe_set_seed( &mut self, seed: Option<ProfileSeed>, ) -> &mut ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn with_seed(self, seed: ProfileSeed) -> ProfileEmulateLayer<P>
pub fn with_seed(self, seed: ProfileSeed) -> ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn set_seed(&mut self, seed: ProfileSeed) -> &mut ProfileEmulateLayer<P>
pub fn set_seed(&mut self, seed: ProfileSeed) -> &mut ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn without_seed(self) -> ProfileEmulateLayer<P>
pub fn without_seed(self) -> ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn unset_seed(&mut self) -> &mut ProfileEmulateLayer<P>
pub fn unset_seed(&mut self) -> &mut ProfileEmulateLayer<P>
Fix the profile seed for reproducible selection.
pub fn maybe_with_connection_key(
self,
key: Option<DrawKey>,
) -> ProfileEmulateLayer<P>
pub fn maybe_with_connection_key( self, key: Option<DrawKey>, ) -> ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn maybe_set_connection_key(
&mut self,
key: Option<DrawKey>,
) -> &mut ProfileEmulateLayer<P>
pub fn maybe_set_connection_key( &mut self, key: Option<DrawKey>, ) -> &mut ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn with_connection_key(self, key: DrawKey) -> ProfileEmulateLayer<P>
pub fn with_connection_key(self, key: DrawKey) -> ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn set_connection_key(
&mut self,
key: DrawKey,
) -> &mut ProfileEmulateLayer<P>
pub fn set_connection_key( &mut self, key: DrawKey, ) -> &mut ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn without_connection_key(self) -> ProfileEmulateLayer<P>
pub fn without_connection_key(self) -> ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn unset_connection_key(&mut self) -> &mut ProfileEmulateLayer<P>
pub fn unset_connection_key(&mut self) -> &mut ProfileEmulateLayer<P>
Fix the logical connection draw key.
pub fn maybe_with_request_key(
self,
key: Option<DrawKey>,
) -> ProfileEmulateLayer<P>
pub fn maybe_with_request_key( self, key: Option<DrawKey>, ) -> ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn maybe_set_request_key(
&mut self,
key: Option<DrawKey>,
) -> &mut ProfileEmulateLayer<P>
pub fn maybe_set_request_key( &mut self, key: Option<DrawKey>, ) -> &mut ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn with_request_key(self, key: DrawKey) -> ProfileEmulateLayer<P>
pub fn with_request_key(self, key: DrawKey) -> ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn set_request_key(&mut self, key: DrawKey) -> &mut ProfileEmulateLayer<P>
pub fn set_request_key(&mut self, key: DrawKey) -> &mut ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn without_request_key(self) -> ProfileEmulateLayer<P>
pub fn without_request_key(self) -> ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn unset_request_key(&mut self) -> &mut ProfileEmulateLayer<P>
pub fn unset_request_key(&mut self) -> &mut ProfileEmulateLayer<P>
Fix the logical request draw key.
pub fn with_pins(self, pins: VariantPins) -> ProfileEmulateLayer<P>
pub fn with_pins(self, pins: VariantPins) -> ProfileEmulateLayer<P>
Pin stored connection and request variants.
pub fn set_pins(&mut self, pins: VariantPins) -> &mut ProfileEmulateLayer<P>
pub fn set_pins(&mut self, pins: VariantPins) -> &mut ProfileEmulateLayer<P>
Pin stored connection and request variants.
pub fn with_is_optional(self, optional: bool) -> ProfileEmulateLayer<P>
pub fn with_is_optional(self, optional: bool) -> ProfileEmulateLayer<P>
Pass requests through unchanged, with a debug trace, when they cannot be emulated instead of failing them.
pub fn set_is_optional(&mut self, optional: bool) -> &mut ProfileEmulateLayer<P>
pub fn set_is_optional(&mut self, optional: bool) -> &mut ProfileEmulateLayer<P>
Pass requests through unchanged, with a debug trace, when they cannot be emulated instead of failing them.
pub fn with_try_auto_detect_user_agent(
self,
detect: bool,
) -> ProfileEmulateLayer<P>
pub fn with_try_auto_detect_user_agent( self, detect: bool, ) -> ProfileEmulateLayer<P>
pub fn set_try_auto_detect_user_agent(
&mut self,
detect: bool,
) -> &mut ProfileEmulateLayer<P>
pub fn set_try_auto_detect_user_agent( &mut self, detect: bool, ) -> &mut ProfileEmulateLayer<P>
pub fn with_select_fallback(
self,
fallback: ProfileSelectFallback,
) -> ProfileEmulateLayer<P>
pub fn with_select_fallback( self, fallback: ProfileSelectFallback, ) -> ProfileEmulateLayer<P>
Choose how to relax the selector when no profile matches it.
pub fn set_select_fallback(
&mut self,
fallback: ProfileSelectFallback,
) -> &mut ProfileEmulateLayer<P>
pub fn set_select_fallback( &mut self, fallback: ProfileSelectFallback, ) -> &mut ProfileEmulateLayer<P>
Choose how to relax the selector when no profile matches it.
pub fn maybe_with_input_header_order(
self,
name: Option<HeaderName>,
) -> ProfileEmulateLayer<P>
pub fn maybe_with_input_header_order( self, name: Option<HeaderName>, ) -> ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
pub fn maybe_set_input_header_order(
&mut self,
name: Option<HeaderName>,
) -> &mut ProfileEmulateLayer<P>
pub fn maybe_set_input_header_order( &mut self, name: Option<HeaderName>, ) -> &mut ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
pub fn with_input_header_order(self, name: HeaderName) -> ProfileEmulateLayer<P>
pub fn with_input_header_order(self, name: HeaderName) -> ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
pub fn set_input_header_order(
&mut self,
name: HeaderName,
) -> &mut ProfileEmulateLayer<P>
pub fn set_input_header_order( &mut self, name: HeaderName, ) -> &mut ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
pub fn without_input_header_order(self) -> ProfileEmulateLayer<P>
pub fn without_input_header_order(self) -> ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
pub fn unset_input_header_order(&mut self) -> &mut ProfileEmulateLayer<P>
pub fn unset_input_header_order(&mut self) -> &mut ProfileEmulateLayer<P>
Name a request header holding a comma-separated list of header names.
Caller headers the profile does not own are emitted in that order, ahead of other caller headers. The header itself is removed from the request.
Trait Implementations§
§impl<P> Clone for ProfileEmulateLayer<P>where
P: Clone,
impl<P> Clone for ProfileEmulateLayer<P>where
P: Clone,
§fn clone(&self) -> ProfileEmulateLayer<P>
fn clone(&self) -> ProfileEmulateLayer<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<P> Debug for ProfileEmulateLayer<P>where
P: Debug,
impl<P> Debug for ProfileEmulateLayer<P>where
P: Debug,
§impl<S, P> Layer<S> for ProfileEmulateLayer<P>where
P: Clone,
impl<S, P> Layer<S> for ProfileEmulateLayer<P>where
P: Clone,
§type Service = ProfileEmulateService<S, P>
type Service = ProfileEmulateService<S, P>
§fn layer(&self, inner: S) -> <ProfileEmulateLayer<P> as Layer<S>>::Service
fn layer(&self, inner: S) -> <ProfileEmulateLayer<P> as Layer<S>>::Service
§fn into_layer(self, inner: S) -> <ProfileEmulateLayer<P> as Layer<S>>::Service
fn into_layer(self, inner: S) -> <ProfileEmulateLayer<P> as Layer<S>>::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl<P = Arc<UserAgentDatabase>> !Freeze for ProfileEmulateLayer<P>
impl<P> Forget for ProfileEmulateLayer<P>
impl<P> Move for ProfileEmulateLayer<P>
impl<P> RefUnwindSafe for ProfileEmulateLayer<P>
impl<P> Send for ProfileEmulateLayer<P>
impl<P> Sync for ProfileEmulateLayer<P>
impl<P> Unpin for ProfileEmulateLayer<P>
impl<P> UnsafeUnpin for ProfileEmulateLayer<P>where
P: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<str>: UnsafeUnpin,
*const u8: UnsafeUnpin,
Align8<*mut ()>: UnsafeUnpin,
&'static Vtable: UnsafeUnpin,
impl<P> UnwindSafe for ProfileEmulateLayer<P>where
P: UnwindSafe,
BoxRaw<str>: UnwindSafe,
*const u8: UnwindSafe,
Align8<*mut ()>: UnwindSafe,
&'static Vtable: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more