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 { ... }
}
Expand description

Trait containing all Session methods.

§Implementors

Session

Provided Methods§

source

fn abort(&self)

Cancels all pending requests in @self and closes all idle persistent connections.

source

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

source

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

source

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

source

fn accepts_language_auto(&self) -> bool

Gets whether @self automatically sets the “Accept-Language” header on new requests.

§Returns

true if @self sets “Accept-Language” header automatically, or false otherwise.

source

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.

source

fn feature(&self, feature_type: Type) -> Option<SessionFeature>

Gets the feature in @self of type @feature_type.

§feature_type

the #GType of the feature to get

§Returns

a #SoupSessionFeature, or None. The feature is owned by @self.

source

fn feature_for_message( &self, feature_type: Type, msg: &Message ) -> Option<SessionFeature>

Gets the feature in @self of type @feature_type, provided that it is not disabled for @msg.

§feature_type

the #GType of the feature to get

§msg

a #SoupMessage

§Returns

a #SoupSessionFeature. The feature is owned by @self.

source

fn idle_timeout(&self) -> u32

Get the timeout in seconds for idle connection lifetime currently used by @self.

§Returns

the timeout in seconds

source

fn local_address(&self) -> Option<InetSocketAddress>

Get the gio::InetSocketAddress to use for the client side of connections in @self.

§Returns

a #GInetSocketAddress

source

fn max_conns(&self) -> u32

Get the maximum number of connections that @self can open at once.

§Returns

the maximum number of connections

source

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

source

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

source

fn remote_connectable(&self) -> Option<SocketConnectable>

Gets the remote connectable if one set.

§Returns

the #GSocketConnectable

source

fn timeout(&self) -> u32

Get the timeout in seconds for socket I/O operations currently used by @self.

§Returns

the timeout in seconds

source

fn tls_database(&self) -> Option<TlsDatabase>

Get the gio::TlsDatabase currently used by @self.

§Returns

a #GTlsDatabase

source

fn tls_interaction(&self) -> Option<TlsInteraction>

Get the gio::TlsInteraction currently used by @self.

§Returns

a #GTlsInteraction

source

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

source

fn has_feature(&self, feature_type: Type) -> bool

Tests if @self has at a feature of type @feature_type (which can be the type of either a SessionFeature, or else a subtype of some class managed by another feature, such as Auth).

§feature_type

the #GType of the class of features to check for

§Returns

true or false

source

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

source

fn preconnect_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn remove_feature(&self, feature: &impl IsA<SessionFeature>)

Removes @feature’s functionality from @self.

§feature

a feature that has previously been added to @self

source

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

source

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.

source

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.

source

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

source

fn send_and_read_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<Bytes, Error>> + 'static>>

source

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.

source

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

source

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>>

source

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

source

fn send_future( &self, msg: &Message, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>>

source

fn set_accept_language(&self, accept_language: &str)

Set the value to use for the “Accept-Language” header on Messages 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

source

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

source

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

source

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

source

fn set_timeout(&self, timeout: u32)

Set a timeout in seconds for socket I/O operations to be used by @self on new connections.

See timeout for more information.

§timeout

a timeout in seconds

source

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

source

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

source

fn set_user_agent(&self, user_agent: &str)

Set the value to use for the “User-Agent” header on Messages 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

source

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

source

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

source

fn connect_accept_language_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_accept_language_auto_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_idle_timeout_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_proxy_resolver_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_timeout_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_tls_database_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_tls_interaction_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_user_agent_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§