Soup.Session¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Accept-Language string |
||
r/w |
Accept-Language automatic mode |
||
r/w/co |
The |
||
[ |
r/w |
URI schemes that are considered aliases for ‘http’ |
|
[ |
r/w |
URI schemes that are considered aliases for ‘https’ |
|
r/w |
Connection lifetime when idle |
||
r/w/co |
Address of local end of socket |
||
r/w |
The maximum number of connections that the session can open at once |
||
r/w |
The maximum number of connections that the session can open at once to a given host |
||
r/w |
The |
||
d/r/w |
The HTTP Proxy to use for this session |
||
d/r/w |
File containing SSL CA certificates |
||
r/w |
Whether certificate errors should be considered a connection error |
||
r/w |
Use the system certificate database |
||
r/w |
Value in seconds to timeout a blocking I/O |
||
r/w |
TLS database to use |
||
r/w |
TLS interaction to use |
||
d/r/w |
Whether or not to use NTLM authentication |
||
r/w |
Whether to use thread-default main contexts |
||
r/w |
User-Agent string |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the session requires authentication. |
|
Emitted when a new connection is created. |
|
Emitted when a request is queued on session. |
|
Emitted just before a request is sent. |
|
Emitted when a request is removed from session's queue, indicating that session is done with it. |
|
Emitted when an SSL tunnel is being created on a proxy connection. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Soup.Session(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new()¶
- Returns:
the new session.
- Return type:
Creates a
Soup.Session
with the default options.New in version 2.42.
- abort()¶
Cancels all pending requests in self and closes all idle persistent connections.
The message cancellation has the same semantics as with
Soup.Session.cancel_message
(); asynchronous requests on aSoup.SessionAsync
will have their callback called beforeSoup.Session.abort
() returns. Requests on a plainSoup.Session
will not.
- add_feature(feature)¶
- Parameters:
feature (
Soup.SessionFeature
) – an object that implementsSoup.SessionFeature
Adds feature's functionality to self. You can also add a feature to the session at construct time by using the
Soup.SESSION_ADD_FEATURE
property.See the main
Soup.Session
documentation for information on what features are present in sessions by default.New in version 2.24.
- add_feature_by_type(feature_type)¶
- Parameters:
feature_type (
GObject.GType
) – aGObject.GType
If feature_type is the type of a class that implements
Soup.SessionFeature
, this creates a new feature of that type and adds it to self as withSoup.Session.add_feature
(). You can use this when you don’t need to customize the new feature in any way.If feature_type is not a
Soup.SessionFeature
type, this gives each existing feature on self the chance to accept feature_type as a “subfeature”. This can be used to add newSoup.Auth
orSoup.Request
types, for instance.You can also add a feature to the session at construct time by using the
Soup.SESSION_ADD_FEATURE_BY_TYPE
property.See the main
Soup.Session
documentation for information on what features are present in sessions by default.New in version 2.24.
- cancel_message(msg, status_code)¶
- Parameters:
msg (
Soup.Message
) – the message to cancelstatus_code (
int
) – status code to set on msg (generallySoup.Status.CANCELLED
)
Causes self to immediately finish processing msg (regardless of its current state) with a final status_code of status_code. You may call this at any time after handing msg off to self; if self has started sending the request but has not yet received the complete response, then it will close the request’s connection. 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 the message is cancelled while its response body is being read, then the response body in msg will be left partially-filled-in. The response headers, on the other hand, will always be either empty or complete.
Beware that with the deprecated
Soup.SessionAsync
, messages queued withSoup.Session.queue_message
() will have their callbacks invoked beforeSoup.Session.cancel_message
() returns. The plainSoup.Session
does not have this behavior; cancelling an asynchronous message will merely queue its callback to be run after returning to the main loop.
- connect_async(uri, cancellable, progress_callback, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
progress_callback (
Soup.SessionConnectProgressCallback
orNone
) – aSoup.SessionConnectProgressCallback
which will be called for every network event that occurs during the connection.callback (
Gio.AsyncReadyCallback
orNone
) – the callback to invoke when the operation finishesuser_data (
object
orNone
) – data for progress_callback and callback
Start a connection to uri. The operation can be monitored by providing a progress_callback and finishes when the connection is done or an error ocurred.
Call
Soup.Session.connect_finish
() to get theGio.IOStream
to communicate with the server.New in version 2.62.
- connect_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – theGio.AsyncResult
passed to your callback- Raises:
- Returns:
a new
Gio.IOStream
, orNone
on error.- Return type:
Gets the
Gio.IOStream
created for the connection to communicate with the server.New in version 2.62.
- get_async_context()¶
- Returns:
self's
GLib.MainContext
, which may beNone
- Return type:
Gets self's
Soup.Session
:async-context
. This does not add a ref to the context, so you will need to ref it yourself if you want it to outlive its session.For a modern
Soup.Session
, this will always just return the thread-defaultGLib.MainContext
, and so is not especially useful.
- get_feature(feature_type)¶
- Parameters:
feature_type (
GObject.GType
) – theGObject.GType
of the feature to get- Returns:
a
Soup.SessionFeature
, orNone
. The feature is owned by self.- Return type:
Gets the first feature in self of type feature_type. For features where there may be more than one feature of a given type, use
Soup.Session.get_features
().New in version 2.26.
- get_feature_for_message(feature_type, msg)¶
- Parameters:
feature_type (
GObject.GType
) – theGObject.GType
of the feature to getmsg (
Soup.Message
) – aSoup.Message
- Returns:
a
Soup.SessionFeature
, orNone
. The feature is owned by self.- Return type:
Gets the first feature in self of type feature_type, provided that it is not disabled for msg. As with
Soup.Session.get_feature
(), this should only be used for features where feature_type is only expected to match a single feature. In particular, if there are two matching features, and the first is disabled on msg, and the second is not, then this will returnNone
, not the second feature.New in version 2.28.
- get_features(feature_type)¶
- Parameters:
feature_type (
GObject.GType
) – theGObject.GType
of the class of features to get- Returns:
a list of features. You must free the list, but not its contents
- Return type:
Generates a list of self's features of type feature_type. (If you want to see all features, you can pass %SOUP_TYPE_SESSION_FEATURE for feature_type.)
New in version 2.26.
- has_feature(feature_type)¶
- Parameters:
feature_type (
GObject.GType
) – theGObject.GType
of the class of features to check for- Returns:
- Return type:
Tests if self has at a feature of type feature_type (which can be the type of either a
Soup.SessionFeature
, or else a subtype of some class managed by another feature, such asSoup.Auth
orSoup.Request
).New in version 2.42.
- pause_message(msg)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
currently running on self
Pauses HTTP I/O on msg. Call
Soup.Session.unpause_message
() to resume I/O.This may only be called for asynchronous messages (those sent on a
Soup.SessionAsync
or usingSoup.Session.queue_message
()).
- prefetch_dns(hostname, cancellable, callback, *user_data)¶
- Parameters:
hostname (
str
) – a hostname to be resolvedcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
object, orNone
callback (
Soup.AddressCallback
orNone
) – callback to call with the result, orNone
Tells self that an URI from the given hostname may be requested shortly, and so the session can try to prepare by resolving the domain name in advance, in order to work more quickly once the URI is actually requested.
If cancellable is non-
None
, it can be used to cancel the resolution. callback will still be invoked in this case, with a status ofSoup.Status.CANCELLED
.New in version 2.38.
- prepare_for_uri(uri)¶
-
Tells self that uri may be requested shortly, and so the session can try to prepare (resolving the domain name, obtaining proxy address, etc.) in order to work more quickly once the URI is actually requested.
New in version 2.30.
Deprecated since version 2.38: use
Soup.Session.prefetch_dns
() instead
- queue_message(msg, callback, *user_data)¶
- Parameters:
msg (
Soup.Message
) – the message to queuecallback (
Soup.SessionCallback
orNone
) – aSoup.SessionCallback
which will be called after the message completes or when an unrecoverable error occurs.
Queues the message msg for asynchronously sending the request and receiving a response in the current thread-default
GLib.MainContext
. If msg has been processed before, any resources related to the time it was last sent are freed.Upon message completion, the callback specified in callback will be invoked. If after returning from this callback the message has not been requeued, msg will be unreffed.
(The behavior above applies to a plain
Soup.Session
; if you are usingSoup.SessionAsync
orSoup.SessionSync
, then theGLib.MainContext
that is used depends on the settings ofSoup.Session
:async-context
andSoup.Session
:use-thread-context
, and forSoup.SessionSync
, the message will actually be sent and processed in another thread, with only the final callback occurring in the indicatedGLib.MainContext
.)Contrast this method with
Soup.Session.send_async
(), which also asynchronously sends a message, but returns before reading the response body, and allows you to read the response via aGio.InputStream
.
- redirect_message(msg)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
that has received a 3xx response- Returns:
True
if a redirection was applied,False
if not (eg, because there was no Location header, or it could not be parsed).- Return type:
Updates msg's URI according to its status code and “Location” header, and requeues it on self. Use this when you have set
Soup.MessageFlags.NO_REDIRECT
on a message, but have decided to allow a particular redirection to occur, or if you want to allow a redirection thatSoup.Session
will not perform automatically (eg, redirecting a non-safe method such as DELETE).If msg's status code indicates that it should be retried as a GET request, then msg will be modified accordingly.
If msg has already been redirected too many times, this will cause it to fail with
Soup.Status.TOO_MANY_REDIRECTS
.New in version 2.38.
- remove_feature(feature)¶
- Parameters:
feature (
Soup.SessionFeature
) – a feature that has previously been added to self
Removes feature's functionality from self.
New in version 2.24.
- remove_feature_by_type(feature_type)¶
- Parameters:
feature_type (
GObject.GType
) – aGObject.GType
Removes all features of type feature_type (or any subclass of feature_type) from self. You can also remove standard features from the session at construct time by using the
Soup.SESSION_REMOVE_FEATURE_BY_TYPE
property.New in version 2.24.
- request(uri_string)¶
- Parameters:
uri_string (
str
) – a URI, in string form- Raises:
- Returns:
a new
Soup.Request
, orNone
on error.- Return type:
Creates a
Soup.Request
for retrieving uri_string.New in version 2.42.
- request_http(method, uri_string)¶
- Parameters:
- Raises:
- Returns:
a new
Soup.RequestHTTP
, orNone
on error.- Return type:
Creates a
Soup.Request
for retrieving uri_string, which must be an “http” or “https” URI (or another protocol listed in self'sSoup.Session
:http-aliases
orSoup.Session
:https-aliases
).New in version 2.42.
- request_http_uri(method, uri)¶
- Parameters:
- Raises:
- Returns:
a new
Soup.RequestHTTP
, orNone
on error.- Return type:
Creates a
Soup.Request
for retrieving uri, which must be an “http” or “https” URI (or another protocol listed in self'sSoup.Session
:http-aliases
orSoup.Session
:https-aliases
).New in version 2.42.
- request_uri(uri)¶
- Parameters:
uri (
Soup.URI
) – aSoup.URI
representing the URI to retrieve- Raises:
- Returns:
a new
Soup.Request
, orNone
on error.- Return type:
Creates a
Soup.Request
for retrieving uri.New in version 2.42.
- requeue_message(msg)¶
- Parameters:
msg (
Soup.Message
) – the message to requeue
This causes msg to be placed back on the queue to be attempted again.
- send(msg, cancellable)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
- Raises:
- Returns:
a
Gio.InputStream
for reading the response body, orNone
on error.- Return type:
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;Soup.Session.send
() will return aGio.IOErrorEnum.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
Soup.Session.send
() will only return once a final response has been received.Contrast this method with
Soup.Session.send_message
(), which also synchronously sends aSoup.Message
, but doesn’t return until the response has been completely read.(Note that this method cannot be called on the deprecated
Soup.SessionAsync
subclass.)New in version 2.42.
- send_async(msg, cancellable, callback, *user_data)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
callback (
Gio.AsyncReadyCallback
orNone
) – the callback to invoke
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
Soup.Session.send_finish
() to get aGio.InputStream
for reading the response body.See
Soup.Session.send
() for more details on the general semantics.Contrast this method with
Soup.Session.queue_message
(), which also asynchronously sends aSoup.Message
, but doesn’t invoke its callback until the response has been completely read.(Note that this method cannot be called on the deprecated
Soup.SessionSync
subclass, and can only be called onSoup.SessionAsync
if you have set theSoup.Session
:use-thread-context
property.)New in version 2.42.
- send_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – theGio.AsyncResult
passed to your callback- Raises:
- Returns:
a
Gio.InputStream
for reading the response body, orNone
on error.- Return type:
Gets the response to a
Soup.Session.send_async
() call and (if successful), returns aGio.InputStream
that can be used to read the response body.New in version 2.42.
- send_message(msg)¶
- Parameters:
msg (
Soup.Message
) – the message to send- Returns:
the HTTP status code of the response
- Return type:
Synchronously send msg. This call will not return until the transfer is finished successfully or there is an unrecoverable error.
Unlike with
Soup.Session.queue_message
(), msg is not freed upon return.(Note that if you call this method on a
Soup.SessionAsync
, it will still use asynchronous I/O internally, running the glib main loop to process the message, which may also cause other events to be processed.)Contrast this method with
Soup.Session.send
(), which also synchronously sends a message, but returns before reading the response body, and allows you to read the response via aGio.InputStream
.
- steal_connection(msg)¶
- Parameters:
msg (
Soup.Message
) – the message whose connection is to be stolen- Returns:
the
Gio.IOStream
formerly associated with msg (orNone
if msg was no longer associated with a connection). No guarantees are made about what kind ofGio.IOStream
is returned.- Return type:
“Steals” the HTTP connection associated with msg from self. This happens immediately, regardless of the current state of the connection, and msg's callback will not be called. You can steal the connection from a
Soup.Message
signal handler if you need to wait for part or all of the response to be received first.Calling this function may cause msg to be freed if you are not holding any other reference to it.
New in version 2.50.
- unpause_message(msg)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
currently running on self
Resumes HTTP I/O on msg. Use this to resume after calling
Soup.Session.pause_message
().If msg is being sent via blocking I/O, this will resume reading or writing immediately. If msg is using non-blocking I/O, then reading or writing won’t resume until you return to the main loop.
This may only be called for asynchronous messages (those sent on a
Soup.SessionAsync
or usingSoup.Session.queue_message
()).
- websocket_connect_async(msg, origin, protocols, cancellable, callback, *user_data)¶
- Parameters:
msg (
Soup.Message
) –Soup.Message
indicating the WebSocket server to connect toprotocols ([
str
] orNone
) – aNone
-terminated array of protocols supportedcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
callback (
Gio.AsyncReadyCallback
orNone
) – the callback to invoke
Asynchronously creates a
Soup.WebsocketConnection
to communicate with a remote server.All necessary WebSocket-related headers will be added to msg, and it will then be sent and asynchronously processed normally (including handling of redirection and HTTP authentication).
If the server returns “101 Switching Protocols”, then msg's status code and response headers will be updated, and then the WebSocket handshake will be completed. On success,
Soup.Session.websocket_connect_finish
() will return a newSoup.WebsocketConnection
. On failure it will return aGLib.Error
.If the server returns a status other than “101 Switching Protocols”, then msg will contain the complete response headers and body from the server’s response, and
Soup.Session.websocket_connect_finish
() will returnSoup.WebsocketError.NOT_WEBSOCKET
.New in version 2.50.
- websocket_connect_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – theGio.AsyncResult
passed to your callback- Raises:
- Returns:
a new
Soup.WebsocketConnection
, orNone
on error.- Return type:
Gets the
Soup.WebsocketConnection
response to aSoup.Session.websocket_connect_async
() call and (if successful), returns aSoup.WebsocketConnection
that can be used to communicate with the server.New in version 2.50.
- would_redirect(msg)¶
- Parameters:
msg (
Soup.Message
) – aSoup.Message
that has response headers- Returns:
whether msg would be redirected
- Return type:
Checks if msg contains a response that would cause self to redirect it to a new URL (ignoring msg's
Soup.MessageFlags.NO_REDIRECT
flag, and the number of times it has already been redirected).New in version 2.38.
- do_auth_required(msg, auth, retrying) virtual¶
- Parameters:
msg (
Soup.Message
) –auth (
Soup.Auth
) –retrying (
bool
) –
- do_authenticate(msg, auth, retrying) virtual¶
- Parameters:
msg (
Soup.Message
) –auth (
Soup.Auth
) –retrying (
bool
) –
- do_cancel_message(msg, status_code) virtual¶
- Parameters:
msg (
Soup.Message
) – the message to cancelstatus_code (
int
) – status code to set on msg (generallySoup.Status.CANCELLED
)
Causes session to immediately finish processing msg (regardless of its current state) with a final status_code of status_code. You may call this at any time after handing msg off to session; if session has started sending the request but has not yet received the complete response, then it will close the request’s connection. 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 the message is cancelled while its response body is being read, then the response body in msg will be left partially-filled-in. The response headers, on the other hand, will always be either empty or complete.
Beware that with the deprecated
Soup.SessionAsync
, messages queued withSoup.Session.queue_message
() will have their callbacks invoked beforeSoup.Session.cancel_message
() returns. The plainSoup.Session
does not have this behavior; cancelling an asynchronous message will merely queue its callback to be run after returning to the main loop.
- do_flush_queue() virtual¶
- do_kick() virtual¶
- do_queue_message(msg, callback, *user_data) virtual¶
- Parameters:
msg (
Soup.Message
) – the message to queuecallback (
Soup.SessionCallback
orNone
) – aSoup.SessionCallback
which will be called after the message completes or when an unrecoverable error occurs.
Queues the message msg for asynchronously sending the request and receiving a response in the current thread-default
GLib.MainContext
. If msg has been processed before, any resources related to the time it was last sent are freed.Upon message completion, the callback specified in callback will be invoked. If after returning from this callback the message has not been requeued, msg will be unreffed.
(The behavior above applies to a plain
Soup.Session
; if you are usingSoup.SessionAsync
orSoup.SessionSync
, then theGLib.MainContext
that is used depends on the settings ofSoup.Session
:async-context
andSoup.Session
:use-thread-context
, and forSoup.SessionSync
, the message will actually be sent and processed in another thread, with only the final callback occurring in the indicatedGLib.MainContext
.)Contrast this method with
Soup.Session.send_async
(), which also asynchronously sends a message, but returns before reading the response body, and allows you to read the response via aGio.InputStream
.
- do_request_started(msg, socket) virtual¶
- Parameters:
msg (
Soup.Message
) –socket (
Soup.Socket
) –
- do_requeue_message(msg) virtual¶
- Parameters:
msg (
Soup.Message
) – the message to requeue
This causes msg to be placed back on the queue to be attempted again.
- do_send_message(msg) virtual¶
- Parameters:
msg (
Soup.Message
) – the message to send- Returns:
the HTTP status code of the response
- Return type:
Synchronously send msg. This call will not return until the transfer is finished successfully or there is an unrecoverable error.
Unlike with
Soup.Session.queue_message
(), msg is not freed upon return.(Note that if you call this method on a
Soup.SessionAsync
, it will still use asynchronous I/O internally, running the glib main loop to process the message, which may also cause other events to be processed.)Contrast this method with
Soup.Session.send
(), which also synchronously sends a message, but returns before reading the response body, and allows you to read the response via aGio.InputStream
.
Signal Details¶
- Soup.Session.signals.authenticate(session, msg, auth, retrying)¶
- Signal Name:
authenticate
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalmsg (
Soup.Message
) – theSoup.Message
being sentretrying (
bool
) –True
if this is the second (or later) attempt
Emitted when the session requires authentication. If credentials are available call
Soup.Auth.authenticate
() on auth. If these credentials fail, the signal will be emitted again, with retrying set toTrue
, which will continue until you return without callingSoup.Auth.authenticate
() on auth.Note that this may be emitted before msg's body has been fully read.
If you call
Soup.Session.pause_message
() on msg before returning, then you can authenticate auth asynchronously (as long as youGObject.Object.ref
() it to make sure it doesn’t get destroyed), and then unpause msg when you are ready for it to continue.
- Soup.Session.signals.connection_created(session, connection)¶
- Signal Name:
connection-created
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalconnection (
GObject.Object
) – the connection
Emitted when a new connection is created. This is an internal signal intended only to be used for debugging purposes, and may go away in the future.
New in version 2.30.
- Soup.Session.signals.request_queued(session, msg)¶
- Signal Name:
request-queued
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalmsg (
Soup.Message
) – the request that was queued
Emitted when a request is queued on session. (Note that “queued” doesn’t just mean
Soup.Session.queue_message
();Soup.Session.send_message
() implicitly queues the message as well.)When sending a request, first #SoupSession::request_queued is emitted, indicating that the session has become aware of the request.
Once a connection is available to send the request on, the session emits #SoupSession::request_started. Then, various
Soup.Message
signals are emitted as the message is processed. If the message is requeued, it will emitSoup.Message
::restarted
, which will then be followed by another #SoupSession::request_started and another set ofSoup.Message
signals when the message is re-sent.Eventually, the message will emit
Soup.Message
::finished
. Normally, this signals the completion of message processing. However, it is possible that the application will requeue the message from the “finished” handler (or equivalently, from theSoup.Session.queue_message
() callback). In that case, the process will loop back to #SoupSession::request_started.Eventually, a message will reach “finished” and not be requeued. At that point, the session will emit #SoupSession::request_unqueued to indicate that it is done with the message.
To sum up: #SoupSession::request_queued and #SoupSession::request_unqueued are guaranteed to be emitted exactly once, but #SoupSession::request_started and
Soup.Message
::finished
(and all of the otherSoup.Message
signals) may be invoked multiple times for a given message.New in version 2.24.
- Soup.Session.signals.request_started(session, msg, socket)¶
- Signal Name:
request-started
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalmsg (
Soup.Message
) – the request being sentsocket (
Soup.Socket
) – the socket the request is being sent on
Emitted just before a request is sent. See #SoupSession::request_queued for a detailed description of the message lifecycle within a session.
Deprecated since version 2.50.: Use
Soup.Message
::starting
instead.
- Soup.Session.signals.request_unqueued(session, msg)¶
- Signal Name:
request-unqueued
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalmsg (
Soup.Message
) – the request that was unqueued
Emitted when a request is removed from session's queue, indicating that session is done with it. See #SoupSession::request_queued for a detailed description of the message lifecycle within a session.
New in version 2.24.
- Soup.Session.signals.tunneling(session, connection)¶
- Signal Name:
tunneling
- Flags:
- Parameters:
session (
Soup.Session
) – The object which received the signalconnection (
GObject.Object
) – the connection
Emitted when an SSL tunnel is being created on a proxy connection. This is an internal signal intended only to be used for debugging purposes, and may go away in the future.
New in version 2.30.
Property Details¶
- Soup.Session.props.accept_language¶
-
If non-
None
, the value to use for the “Accept-Language” header onSoup.Message
s sent from this session.Setting this will disable
Soup.Session
:accept-language-auto
.New in version 2.30.
- Soup.Session.props.accept_language_auto¶
-
If
True
,Soup.Session
will automatically set the string for the “Accept-Language” header on everySoup.Message
sent, based on the return value ofGLib.get_language_names
().Setting this will override any previous value of
Soup.Session
:accept-language
.New in version 2.30.
- Soup.Session.props.async_context¶
- Name:
async-context
- Type:
- Default Value:
- Flags:
The
GLib.MainContext
that miscellaneous session-related asynchronous callbacks are invoked on. (Eg, settingSoup.Session
:idle-timeout
will add a timeout source on this context.)For a plain
Soup.Session
, this property is always set to theGLib.MainContext
that is the thread-default at the time the session was created, and cannot be overridden. For the deprecatedSoup.Session
subclasses, the default value isNone
, meaning to use the global defaultGLib.MainContext
.If
Soup.Session
:use-thread-context
isFalse
, this context will also be used for asynchronous HTTP I/O.
- Soup.Session.props.http_aliases¶
-
A
None
-terminated array of URI schemes that should be considered to be aliases for “http”. Eg, if this included"dav"
, than a URI ofdav://example.com/path
would be treated identically tohttp://example.com/path
.In a plain
Soup.Session
, the default value isNone
, meaning that only “http” is recognized as meaning “http”. InSoup.SessionAsync
andSoup.SessionSync
, for backward compatibility, the default value is an array containing the single element"*"
, a special value which means that any scheme except “https” is considered to be an alias for “http”.See also
Soup.Session
:https-aliases
.New in version 2.38.
- Soup.Session.props.https_aliases¶
-
A comma-delimited list of URI schemes that should be considered to be aliases for “https”. See
Soup.Session
:http-aliases
for more information.The default value is
None
, meaning that no URI schemes are considered aliases for “https”.New in version 2.38.
- Soup.Session.props.idle_timeout¶
-
Connection lifetime (in seconds) when idle. Any connection left idle longer than this will be closed.
Although you can change this property at any time, it will only affect newly-created connections, not currently-open ones. You can call
Soup.Session.abort
() after setting this if you want to ensure that all future connections will have this timeout value.Note that the default value of 60 seconds only applies to plain
Soup.Sessions
. If you are usingSoup.SessionAsync
orSoup.SessionSync
, the default value is 0 (meaning idle connections will never time out).New in version 2.24.
- Soup.Session.props.local_address¶
- Name:
local-address
- Type:
- Default Value:
- Flags:
Sets the
Soup.Address
to use for the client side of the connection.Use this property if you want for instance to bind the local socket to a specific IP address.
New in version 2.42.
- Soup.Session.props.max_conns¶
-
The maximum number of connections that the session can open at once
- Soup.Session.props.max_conns_per_host¶
-
The maximum number of connections that the session can open at once to a given host
- Soup.Session.props.proxy_resolver¶
- Name:
proxy-resolver
- Type:
- Default Value:
- Flags:
A
Gio.ProxyResolver
to use with this session. Setting this will clear theSoup.Session
:proxy-uri
property, and remove anySoupProxyURIResolver
features that have been added to the session.By default, in a plain
Soup.Session
, this is set to the defaultGio.ProxyResolver
, but you can set it toNone
if you don’t want to use proxies, or set it to your ownGio.ProxyResolver
if you want to control what proxies get used.New in version 2.42.
- Soup.Session.props.proxy_uri¶
- Name:
proxy-uri
- Type:
- Default Value:
- Flags:
A proxy to use for all http and https requests in this session. Setting this will clear the
Soup.Session
:proxy-resolver
property, and remove anySoupProxyURIResolver
features that have been added to the session. Setting this property will also cancel all currently pending messages.Note that
Soup.Session
will normally handle looking up the user’s proxy settings for you; you should only useSoup.Session
:proxy-uri
if you need to override the user’s normal proxy settings.Also note that this proxy will be used for all requests; even requests to
localhost
. If you need more control over proxies, you can create aGio.SimpleProxyResolver
and set theSoup.Session
:proxy-resolver
property.Deprecated since version 2.70: Use
Soup.Session
:proxy-resolver
along withGio.SimpleProxyResolver
.
- Soup.Session.props.ssl_ca_file¶
- Name:
ssl-ca-file
- Type:
- Default Value:
- Flags:
File containing SSL CA certificates.
If the specified file does not exist or cannot be read, then libsoup will print a warning, and then behave as though it had read in a empty CA file, meaning that all SSL certificates will be considered invalid.
Deprecated since version ???: use
Soup.Session
:ssl-use-system-ca-file
, or elseSoup.Session
:tls-database
with aGio.TlsFileDatabase
(which allows you to do explicit error handling).
- Soup.Session.props.ssl_strict¶
-
Normally, if
Soup.Session
:tls-database
is set (including if it was set viaSoup.Session
:ssl-use-system-ca-file
orSoup.Session
:ssl-ca-file
), then libsoup will reject any certificate that is invalid (ie, expired) or that is not signed by one of the given CA certificates, and theSoup.Message
will fail with the statusSoup.Status.SSL_FAILED
.If you set
Soup.Session
:ssl-strict
toFalse
, then all certificates will be accepted, and you will need to callSoup.Message.get_https_status
() to distinguish valid from invalid certificates. (This can be used, eg, if you want to accept invalid certificates after giving some sort of warning.)For a plain
Soup.Session
, if the session has no CA file or TLS database, and this property isTrue
, then all certificates will be rejected. However, beware that the deprecatedSoup.Session
subclasses (Soup.SessionAsync
andSoup.SessionSync
) have the opposite behavior: if there is no CA file or TLS database, then all certificates are always accepted, and this property has no effect.New in version 2.30.
- Soup.Session.props.ssl_use_system_ca_file¶
-
Setting this to
True
is equivalent to settingSoup.Session
:tls-database
to the default system CA database. (and likewise, settingSoup.Session
:tls-database
to the default database by hand will cause this property to becomeTrue
).Setting this to
False
(when it was previouslyTrue
) will clear theSoup.Session
:tls-database
field.See
Soup.Session
:ssl-strict
for more information on how https certificate validation is handled.If you are using
Soup.SessionAsync
orSoup.SessionSync
, on libsoup older than 2.74.0, the default value isFalse
, for backward compatibility.New in version 2.38.
- Soup.Session.props.timeout¶
-
The timeout (in seconds) for socket I/O operations (including connecting to a server, and waiting for a reply to an HTTP request).
Although you can change this property at any time, it will only affect newly-created connections, not currently-open ones. You can call
Soup.Session.abort
() after setting this if you want to ensure that all future connections will have this timeout value.Note that the default value of 60 seconds only applies to plain
Soup.Sessions
. If you are usingSoup.SessionAsync
orSoup.SessionSync
, the default value is 0 (meaning socket I/O will not time out).Not to be confused with
Soup.Session
:idle-timeout
(which is the length of time that idle persistent connections will be kept open).
- Soup.Session.props.tls_database¶
- Name:
tls-database
- Type:
- Default Value:
- Flags:
Sets the
Gio.TlsDatabase
to use for validating SSL/TLS certificates.Note that setting the
Soup.Session
:ssl-ca-file
orSoup.Session
:ssl-use-system-ca-file
property will cause this property to be set to aGio.TlsDatabase
corresponding to the indicated file or system default.See
Soup.Session
:ssl-strict
for more information on how https certificate validation is handled.If you are using a plain
Soup.Session
thenSoup.Session
:ssl-use-system-ca-file
will beTrue
by default, and so this property will be a copy of the system CA database. If you are usingSoup.SessionAsync
orSoup.SessionSync
, on libsoup older than 2.74.0, this property will beNone
by default.New in version 2.38.
- Soup.Session.props.tls_interaction¶
- Name:
tls-interaction
- Type:
- Default Value:
- Flags:
A
Gio.TlsInteraction
object that will be passed on to anyGio.TlsConnections
created by the session. (This can be used to provide client-side certificates, for example.)New in version 2.48.
- Soup.Session.props.use_ntlm¶
- Name:
use-ntlm
- Type:
- Default Value:
- Flags:
Whether or not to use NTLM authentication.
Deprecated since version ???: use
Soup.Session.add_feature_by_type
() with #SOUP_TYPE_AUTH_NTLM.
- Soup.Session.props.use_thread_context¶
-
If
True
(which it always is on a plainSoup.Session
), asynchronous HTTP requests in this session will run in whatever the thread-defaultGLib.MainContext
is at the time they are started, rather than always occurring inSoup.Session
:async-context
.New in version 2.38.
- Soup.Session.props.user_agent¶
-
If non-
None
, the value to use for the “User-Agent” header onSoup.Message
s sent from this session.RFC 2616 says: “The User-Agent request-header field contains information about the user agent originating the request. This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations. User agents SHOULD include this field with requests.”
The User-Agent header contains a list of one or more product tokens, separated by whitespace, with the most significant product token coming first. The tokens must be brief, ASCII, and mostly alphanumeric (although “-”, “_”, and “.” are also allowed), and may optionally include a “/” followed by a version string. You may also put comments, enclosed in parentheses, between or after the tokens.
If you set a #SoupSession:user_agent property that has trailing whitespace,
Soup.Session
will append its own product token (eg, “libsoup/2.3.2
”) to the end of the header for you.