pub struct UserAgentEmulateService<S, P> { /* private fields */ }Expand description
Service to select a UserAgentProfile and inject its info into the input Extensions.
Note that actual http emulation is done by also ensuring a service
such as UserAgentEmulateHttpRequestModifier and UserAgentEmulateHttpConnectModifier is in use within your connector stack.
Tls emulation is facilitated by a tls client connector which respects
the injected (tls) client profile.
See the implementation ofEasyHttpWebClient for the reference implementation of how
one can make use of this profile to emulate a user agent on the tls layer.
Implementations§
Source§impl<S, P> UserAgentEmulateService<S, P>
impl<S, P> UserAgentEmulateService<S, P>
Sourcepub fn new(inner: S, provider: P) -> Self
pub fn new(inner: S, provider: P) -> Self
Create a new UserAgentEmulateService with the given inner service and provider.
Provider is implicitly expected to be a UserAgentProvider.
Sourcepub fn with_is_optional(self, optional: bool) -> Self
pub fn with_is_optional(self, optional: bool) -> Self
When no user agent profile was found it will fail the request unless optional is true. In case of the latter the service will do nothing.
Sourcepub fn set_is_optional(&mut self, optional: bool) -> &mut Self
pub fn set_is_optional(&mut self, optional: bool) -> &mut Self
When no user agent profile was found it will fail the request unless optional is true. In case of the latter the service will do nothing.
Sourcepub fn with_try_auto_detect_user_agent(
self,
try_auto_detect_user_agent: bool,
) -> Self
pub fn with_try_auto_detect_user_agent( self, try_auto_detect_user_agent: bool, ) -> Self
If true, the service will try to auto-detect the user agent from the request, but only in case that info is not yet found in the context.
Sourcepub fn set_try_auto_detect_user_agent(
&mut self,
try_auto_detect_user_agent: bool,
) -> &mut Self
pub fn set_try_auto_detect_user_agent( &mut self, try_auto_detect_user_agent: bool, ) -> &mut Self
If true, the service will try to auto-detect the user agent from the request, but only in case that info is not yet found in the context.
Sourcepub fn maybe_with_input_header_order(self, name: Option<HeaderName>) -> Self
pub fn maybe_with_input_header_order(self, name: Option<HeaderName>) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn maybe_set_input_header_order(
&mut self,
name: Option<HeaderName>,
) -> &mut Self
pub fn maybe_set_input_header_order( &mut self, name: Option<HeaderName>, ) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn with_input_header_order(self, name: HeaderName) -> Self
pub fn with_input_header_order(self, name: HeaderName) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn set_input_header_order(&mut self, name: HeaderName) -> &mut Self
pub fn set_input_header_order(&mut self, name: HeaderName) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn without_input_header_order(self) -> Self
pub fn without_input_header_order(self) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn unset_input_header_order(&mut self) -> &mut Self
pub fn unset_input_header_order(&mut self) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn maybe_with_select_fallback(
self,
fb: Option<UserAgentSelectFallback>,
) -> Self
pub fn maybe_with_select_fallback( self, fb: Option<UserAgentSelectFallback>, ) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn maybe_set_select_fallback(
&mut self,
fb: Option<UserAgentSelectFallback>,
) -> &mut Self
pub fn maybe_set_select_fallback( &mut self, fb: Option<UserAgentSelectFallback>, ) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn with_select_fallback(self, fb: UserAgentSelectFallback) -> Self
pub fn with_select_fallback(self, fb: UserAgentSelectFallback) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn set_select_fallback(&mut self, fb: UserAgentSelectFallback) -> &mut Self
pub fn set_select_fallback(&mut self, fb: UserAgentSelectFallback) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn without_select_fallback(self) -> Self
pub fn without_select_fallback(self) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn unset_select_fallback(&mut self) -> &mut Self
pub fn unset_select_fallback(&mut self) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Trait Implementations§
Source§impl<S: Clone, P: Clone> Clone for UserAgentEmulateService<S, P>
impl<S: Clone, P: Clone> Clone for UserAgentEmulateService<S, P>
Source§fn clone(&self) -> UserAgentEmulateService<S, P>
fn clone(&self) -> UserAgentEmulateService<S, P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Body, S, P> Service<Request<Body>> for UserAgentEmulateService<S, P>
impl<Body, S, P> Service<Request<Body>> for UserAgentEmulateService<S, P>
Auto Trait Implementations§
impl<S, P> !Freeze for UserAgentEmulateService<S, P>
impl<S, P> RefUnwindSafe for UserAgentEmulateService<S, P>where
S: RefUnwindSafe,
P: RefUnwindSafe,
impl<S, P> Send for UserAgentEmulateService<S, P>
impl<S, P> Sync for UserAgentEmulateService<S, P>
impl<S, P> Unpin for UserAgentEmulateService<S, P>
impl<S, P> UnsafeUnpin for UserAgentEmulateService<S, P>where
S: UnsafeUnpin,
P: UnsafeUnpin,
impl<S, P> UnwindSafe for UserAgentEmulateService<S, P>where
S: UnwindSafe,
P: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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,
Source§impl<S, Input, Connection> ConnectorService<Input> for S
impl<S, Input, Connection> ConnectorService<Input> for S
Source§type Connection = Connection
type Connection = Connection
ConnectorServiceSource§type Error = <S as Service<Input>>::Error
type Error = <S as Service<Input>>::Error
Source§fn connect(
&self,
input: Input,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, <S as ConnectorService<Input>>::Error>> + Send
fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, <S as ConnectorService<Input>>::Error>> + Send
Source§impl<S, Body> HttpClientExt for S
impl<S, Body> HttpClientExt for S
Source§type ExecuteResponse = Response<Body>
type ExecuteResponse = Response<Body>
execute method.Source§type ExecuteError = <S as Service<Request>>::Error
type ExecuteError = <S as Service<Request>>::Error
execute method.Source§fn get(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn get( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
GET request to a URL. Read moreSource§fn post(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn post( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
POST request to a URL. Read moreSource§fn put(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn put( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PUT request to a URL. Read moreSource§fn patch(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn patch( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PATCH request to a URL. Read moreSource§fn delete(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn delete( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
DELETE request to a URL. Read moreSource§fn head(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn head( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
HEAD request to a URL. Read moreSource§fn connect(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn connect( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
CONNECT request to a URL. Read moreSource§fn request(
&self,
method: Method,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn request( &self, method: Method, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
Source§fn build_from_request<RequestBody>(
&self,
request: Request<RequestBody>,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn build_from_request<RequestBody>( &self, request: Request<RequestBody>, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
Source§fn execute(
&self,
request: Request,
) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
fn execute( &self, request: Request, ) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
Request. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<S> IntoEndpointService<(S,)> for S
impl<S> IntoEndpointService<(S,)> for S
type Service = S
Source§fn into_endpoint_service(self) -> <S as IntoEndpointService<(S,)>>::Service
fn into_endpoint_service(self) -> <S as IntoEndpointService<(S,)>>::Service
rama_core::Service.Source§impl<S, State> IntoEndpointServiceWithState<(S,), State> for S
impl<S, State> IntoEndpointServiceWithState<(S,), State> for S
type Service = S
Source§fn into_endpoint_service_with_state(
self,
_state: State,
) -> <S as IntoEndpointServiceWithState<(S,), State>>::Service
fn into_endpoint_service_with_state( self, _state: State, ) -> <S as IntoEndpointServiceWithState<(S,), State>>::Service
rama_core::Service with state.