Trait soup::prelude::SessionExt
source · pub trait SessionExt: IsA<Session> + Sealed + 'static {
Show 50 methods
// Provided methods
fn abort(&self) { ... }
fn add_feature(&self, feature: &impl IsA<SessionFeature>) { ... }
fn add_feature_by_type(&self, feature_type: Type) { ... }
fn accept_language(&self) -> Option<GString> { ... }
fn accepts_language_auto(&self) -> bool { ... }
fn async_result_message(
&self,
result: &impl IsA<AsyncResult>
) -> Option<Message> { ... }
fn feature(&self, feature_type: Type) -> Option<SessionFeature> { ... }
fn feature_for_message(
&self,
feature_type: Type,
msg: &Message
) -> Option<SessionFeature> { ... }
fn idle_timeout(&self) -> u32 { ... }
fn local_address(&self) -> Option<InetSocketAddress> { ... }
fn max_conns(&self) -> u32 { ... }
fn max_conns_per_host(&self) -> u32 { ... }
fn proxy_resolver(&self) -> Option<ProxyResolver> { ... }
fn remote_connectable(&self) -> Option<SocketConnectable> { ... }
fn timeout(&self) -> u32 { ... }
fn tls_database(&self) -> Option<TlsDatabase> { ... }
fn tls_interaction(&self) -> Option<TlsInteraction> { ... }
fn user_agent(&self) -> Option<GString> { ... }
fn has_feature(&self, feature_type: Type) -> bool { ... }
fn preconnect_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn preconnect_future(
&self,
msg: &Message,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn remove_feature(&self, feature: &impl IsA<SessionFeature>) { ... }
fn remove_feature_by_type(&self, feature_type: Type) { ... }
fn send(
&self,
msg: &Message,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<InputStream, Error> { ... }
fn send_and_read(
&self,
msg: &Message,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<Bytes, Error> { ... }
fn send_and_read_async<P: FnOnce(Result<Bytes, Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn send_and_read_future(
&self,
msg: &Message,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Bytes, Error>> + 'static>> { ... }
fn send_and_splice(
&self,
msg: &Message,
out_stream: &impl IsA<OutputStream>,
flags: OutputStreamSpliceFlags,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<isize, Error> { ... }
fn send_and_splice_async<P: FnOnce(Result<isize, Error>) + 'static>(
&self,
msg: &Message,
out_stream: &impl IsA<OutputStream>,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn send_and_splice_future(
&self,
msg: &Message,
out_stream: &(impl IsA<OutputStream> + Clone + 'static),
flags: OutputStreamSpliceFlags,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>> { ... }
fn send_async<P: FnOnce(Result<InputStream, Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn send_future(
&self,
msg: &Message,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>> { ... }
fn set_accept_language(&self, accept_language: &str) { ... }
fn set_accept_language_auto(&self, accept_language_auto: bool) { ... }
fn set_idle_timeout(&self, timeout: u32) { ... }
fn set_proxy_resolver(
&self,
proxy_resolver: Option<&impl IsA<ProxyResolver>>
) { ... }
fn set_timeout(&self, timeout: u32) { ... }
fn set_tls_database(&self, tls_database: Option<&impl IsA<TlsDatabase>>) { ... }
fn set_tls_interaction(
&self,
tls_interaction: Option<&impl IsA<TlsInteraction>>
) { ... }
fn set_user_agent(&self, user_agent: &str) { ... }
fn connect_request_queued<F: Fn(&Self, &Message) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_request_unqueued<F: Fn(&Self, &Message) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_accept_language_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_accept_language_auto_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_idle_timeout_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_proxy_resolver_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_timeout_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_tls_database_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_tls_interaction_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_user_agent_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Provided Methods§
sourcefn abort(&self)
fn abort(&self)
Cancels all pending requests in @self and closes all idle persistent connections.
sourcefn add_feature(&self, feature: &impl IsA<SessionFeature>)
fn add_feature(&self, feature: &impl IsA<SessionFeature>)
Adds @feature’s functionality to @self. You cannot add multiple
features of the same alias::GLib.Type
to a session.
See the main #SoupSession documentation for information on what features are present in sessions by default.
§feature
an object that implements #SoupSessionFeature
sourcefn add_feature_by_type(&self, feature_type: Type)
fn add_feature_by_type(&self, feature_type: Type)
If @feature_type is the type of a class that implements
SessionFeature
, this creates a new feature of that type and
adds it to @self as with add_feature()
. You can use
this when you don’t need to customize the new feature in any way.
Adding multiple features of the same @feature_type is not allowed.
If @feature_type is not a SessionFeature
type, this gives each
existing feature on @self the chance to accept @feature_type as
a “subfeature”. This can be used to add new Auth
types, for instance.
See the main #SoupSession documentation for information on what features are present in sessions by default.
§feature_type
a #GType
sourcefn accept_language(&self) -> Option<GString>
fn accept_language(&self) -> Option<GString>
Get the value used by @self for the “Accept-Language” header on new requests.
§Returns
the accept language string
sourcefn accepts_language_auto(&self) -> bool
fn accepts_language_auto(&self) -> bool
sourcefn async_result_message(
&self,
result: &impl IsA<AsyncResult>
) -> Option<Message>
fn async_result_message( &self, result: &impl IsA<AsyncResult> ) -> Option<Message>
Gets the Message
of the @result asynchronous operation This is useful
to get the Message
of an asynchronous operation started by @self
from its `callback::Gio::AsyncReadyCallback.
§result
the #GAsyncResult passed to your callback
§Returns
a #SoupMessage or
None
if @result is not a valid @self async operation result.
sourcefn feature(&self, feature_type: Type) -> Option<SessionFeature>
fn feature(&self, feature_type: Type) -> Option<SessionFeature>
sourcefn feature_for_message(
&self,
feature_type: Type,
msg: &Message
) -> Option<SessionFeature>
fn feature_for_message( &self, feature_type: Type, msg: &Message ) -> Option<SessionFeature>
sourcefn idle_timeout(&self) -> u32
fn idle_timeout(&self) -> u32
Get the timeout in seconds for idle connection lifetime currently used by @self.
§Returns
the timeout in seconds
sourcefn local_address(&self) -> Option<InetSocketAddress>
fn local_address(&self) -> Option<InetSocketAddress>
Get the gio::InetSocketAddress
to use for the client side of
connections in @self.
§Returns
a #GInetSocketAddress
sourcefn max_conns(&self) -> u32
fn max_conns(&self) -> u32
Get the maximum number of connections that @self can open at once.
§Returns
the maximum number of connections
sourcefn max_conns_per_host(&self) -> u32
fn max_conns_per_host(&self) -> u32
Get the maximum number of connections that @self can open at once to a given host.
§Returns
the maximum number of connections per host
sourcefn proxy_resolver(&self) -> Option<ProxyResolver>
fn proxy_resolver(&self) -> Option<ProxyResolver>
Get the gio::ProxyResolver
currently used by @self.
§Returns
a #GProxyResolver or None
if proxies
are disabled in @self
sourcefn remote_connectable(&self) -> Option<SocketConnectable>
fn remote_connectable(&self) -> Option<SocketConnectable>
sourcefn timeout(&self) -> u32
fn timeout(&self) -> u32
Get the timeout in seconds for socket I/O operations currently used by @self.
§Returns
the timeout in seconds
sourcefn tls_database(&self) -> Option<TlsDatabase>
fn tls_database(&self) -> Option<TlsDatabase>
sourcefn tls_interaction(&self) -> Option<TlsInteraction>
fn tls_interaction(&self) -> Option<TlsInteraction>
sourcefn user_agent(&self) -> Option<GString>
fn user_agent(&self) -> Option<GString>
Get the value used by @self for the “User-Agent” header on new requests.
§Returns
the user agent string
sourcefn has_feature(&self, feature_type: Type) -> bool
fn has_feature(&self, feature_type: Type) -> bool
sourcefn preconnect_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn preconnect_async<P: FnOnce(Result<(), Error>) + 'static>( &self, msg: &Message, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Start a preconnection to @msg.
Once the connection is done, it will remain in idle state so that it can be reused by future requests. If there’s already an idle connection for the given @msg host, the operation finishes successfully without creating a new connection. If a new request for the given @msg host is made while the preconnect is still ongoing, the request will take the ownership of the connection and the preconnect operation will finish successfully (if there’s a connection error it will be handled by the request).
The operation finishes when the connection is done or an error occurred.
§msg
a #SoupMessage
§io_priority
the I/O priority of the request
§cancellable
a #GCancellable
§callback
the callback to invoke when the operation finishes
fn preconnect_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn remove_feature(&self, feature: &impl IsA<SessionFeature>)
fn remove_feature(&self, feature: &impl IsA<SessionFeature>)
Removes @feature’s functionality from @self.
§feature
a feature that has previously been added to @self
sourcefn remove_feature_by_type(&self, feature_type: Type)
fn remove_feature_by_type(&self, feature_type: Type)
Removes all features of type @feature_type (or any subclass of @feature_type) from @self.
§feature_type
a #GType
sourcefn send(
&self,
msg: &Message,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<InputStream, Error>
fn send( &self, msg: &Message, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<InputStream, Error>
Synchronously sends @msg and waits for the beginning of a response.
On success, a gio::InputStream
will be returned which you can use to
read the response body. (“Success” here means only that an HTTP
response was received and understood; it does not necessarily mean
that a 2xx class status code was received.)
If non-None
, @cancellable can be used to cancel the request;
send()
will return a G_IO_ERROR_CANCELLED
error. Note that
with requests that have side effects (eg, POST
, PUT
, DELETE
) it is
possible that you might cancel the request after the server acts on it, but
before it returns a response, leaving the remote resource in an unknown
state.
If @msg is requeued due to a redirect or authentication, the
initial (3xx/401/407
) response body will be suppressed, and
send()
will only return once a final response has been
received.
§msg
a #SoupMessage
§cancellable
a #GCancellable
§Returns
a #GInputStream for reading the
response body, or None
on error.
sourcefn send_and_read(
&self,
msg: &Message,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<Bytes, Error>
fn send_and_read( &self, msg: &Message, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Bytes, Error>
Synchronously sends @msg and reads the response body.
On success, a glib::Bytes
will be returned with the response body.
This function should only be used when the resource to be retrieved
is not too long and can be stored in memory.
See send()
for more details on the general semantics.
§msg
a #SoupMessage
§cancellable
a #GCancellable
§Returns
a #GBytes, or None
on error.
sourcefn send_and_read_async<P: FnOnce(Result<Bytes, Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn send_and_read_async<P: FnOnce(Result<Bytes, Error>) + 'static>( &self, msg: &Message, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Asynchronously sends @msg and reads the response body.
When @callback is called, then either @msg has been sent, and its response
body read, or else an error has occurred. This function should only be used
when the resource to be retrieved is not too long and can be stored in
memory. Call Session::send_and_read_finish()
to get a
glib::Bytes
with the response body.
See send()
for more details on the general semantics.
§msg
a #SoupMessage
§io_priority
the I/O priority of the request
§cancellable
a #GCancellable
§callback
the callback to invoke
fn send_and_read_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<Bytes, Error>> + 'static>>
sourcefn send_and_splice(
&self,
msg: &Message,
out_stream: &impl IsA<OutputStream>,
flags: OutputStreamSpliceFlags,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<isize, Error>
fn send_and_splice( &self, msg: &Message, out_stream: &impl IsA<OutputStream>, flags: OutputStreamSpliceFlags, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<isize, Error>
Synchronously sends @msg and splices the response body stream into @out_stream.
See send()
for more details on the general semantics.
§msg
a #SoupMessage
§out_stream
a #GOutputStream
§flags
a set of #GOutputStreamSpliceFlags
§cancellable
a #GCancellable
§Returns
a #gssize containing the size of the data spliced, or -1 if an error occurred.
sourcefn send_and_splice_async<P: FnOnce(Result<isize, Error>) + 'static>(
&self,
msg: &Message,
out_stream: &impl IsA<OutputStream>,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn send_and_splice_async<P: FnOnce(Result<isize, Error>) + 'static>( &self, msg: &Message, out_stream: &impl IsA<OutputStream>, flags: OutputStreamSpliceFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Asynchronously sends @msg and splices the response body stream into @out_stream. When @callback is called, then either @msg has been sent and its response body spliced, or else an error has occurred.
See send()
for more details on the general semantics.
§msg
a #SoupMessage
§out_stream
a #GOutputStream
§flags
a set of #GOutputStreamSpliceFlags
§io_priority
the I/O priority of the request
§cancellable
a #GCancellable
§callback
the callback to invoke
fn send_and_splice_future( &self, msg: &Message, out_stream: &(impl IsA<OutputStream> + Clone + 'static), flags: OutputStreamSpliceFlags, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
sourcefn send_async<P: FnOnce(Result<InputStream, Error>) + 'static>(
&self,
msg: &Message,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn send_async<P: FnOnce(Result<InputStream, Error>) + 'static>( &self, msg: &Message, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Asynchronously sends @msg and waits for the beginning of a response.
When @callback is called, then either @msg has been sent, and its response
headers received, or else an error has occurred. Call
Session::send_finish()
to get a gio::InputStream
for reading the
response body.
See send()
for more details on the general semantics.
§msg
a #SoupMessage
§io_priority
the I/O priority of the request
§cancellable
a #GCancellable
§callback
the callback to invoke
fn send_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>>
sourcefn set_accept_language(&self, accept_language: &str)
fn set_accept_language(&self, accept_language: &str)
Set the value to use for the “Accept-Language” header on Message
s
sent from @self.
If @accept_language is None
then no “Accept-Language” will be included in
requests. See accept-language
for more information.
§accept_language
the languages string
sourcefn set_accept_language_auto(&self, accept_language_auto: bool)
fn set_accept_language_auto(&self, accept_language_auto: bool)
Set whether @self will automatically set the “Accept-Language” header on
requests using a value generated from system languages based on
get_language_names()
.
See accept-language-auto
for more information.
§accept_language_auto
the value to set
sourcefn set_idle_timeout(&self, timeout: u32)
fn set_idle_timeout(&self, timeout: u32)
Set a timeout in seconds for idle connection lifetime to be used by @self on new connections.
See idle-timeout
for more information.
§timeout
a timeout in seconds
sourcefn set_proxy_resolver(&self, proxy_resolver: Option<&impl IsA<ProxyResolver>>)
fn set_proxy_resolver(&self, proxy_resolver: Option<&impl IsA<ProxyResolver>>)
Set a gio::ProxyResolver
to be used by @self on new connections.
If @proxy_resolver is None
then no proxies will be used. See
proxy-resolver
for more information.
§proxy_resolver
a #GProxyResolver or None
sourcefn set_timeout(&self, timeout: u32)
fn set_timeout(&self, timeout: u32)
sourcefn set_tls_database(&self, tls_database: Option<&impl IsA<TlsDatabase>>)
fn set_tls_database(&self, tls_database: Option<&impl IsA<TlsDatabase>>)
Set a GIo::TlsDatabase
to be used by @self on new connections.
If @tls_database is None
then certificate validation will always fail. See
tls-database
for more information.
§tls_database
a #GTlsDatabase
sourcefn set_tls_interaction(
&self,
tls_interaction: Option<&impl IsA<TlsInteraction>>
)
fn set_tls_interaction( &self, tls_interaction: Option<&impl IsA<TlsInteraction>> )
Set a gio::TlsInteraction
to be used by @self on new connections.
If @tls_interaction is None
then client certificate validation will always
fail.
See tls-interaction
for more information.
§tls_interaction
a #GTlsInteraction
sourcefn set_user_agent(&self, user_agent: &str)
fn set_user_agent(&self, user_agent: &str)
Set the value to use for the “User-Agent” header on Message
s sent
from @self.
If @user_agent has trailing whitespace, @self will append its own product
token (eg, libsoup/3.0.0
) to the end of the header for you. If @user_agent
is None
then no “User-Agent” will be included in requests. See
user-agent
for more information.
§user_agent
the user agent string
sourcefn connect_request_queued<F: Fn(&Self, &Message) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_request_queued<F: Fn(&Self, &Message) + 'static>( &self, f: F ) -> SignalHandlerId
Emitted when a request is queued on @session.
When sending a request, first request-queued
is emitted, indicating that the session has become aware of
the request.
After a connection is available to send the request various
Message
signals are emitted as the message is
processed. If the message is requeued, it will emit
restarted
, which will then be followed by other
Message
signals when the message is re-sent.
Eventually, the message will emit finished
.
Normally, this signals the completion of message
processing. However, it is possible that the application
will requeue the message from the “finished” handler.
In that case the process will loop back.
Eventually, a message will reach “finished” and not be
requeued. At that point, the session will emit
request-unqueued
to indicate that it is done
with the message.
To sum up: request-queued
and
request-unqueued
are guaranteed to be emitted
exactly once, but finished
(and all of the other
Message
signals) may be invoked multiple times for a given
message.
§msg
the request that was queued
sourcefn connect_request_unqueued<F: Fn(&Self, &Message) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_request_unqueued<F: Fn(&Self, &Message) + 'static>( &self, f: F ) -> SignalHandlerId
Emitted when a request is removed from @session’s queue, indicating that @session is done with it.
See request-queued
for a detailed description of
the message lifecycle within a session.
§msg
the request that was unqueued