Soup.Session¶
| Subclasses: | Soup.SessionAsync,Soup.SessionSync | 
|---|
Methods¶
| Inherited: | GObject.Object (37) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new() | 
| abort() | |
| add_feature(feature) | |
| add_feature_by_type(feature_type) | |
| cancel_message(msg, status_code) | |
| connect_async(uri, cancellable, progress_callback, callback, *user_data) | |
| connect_finish(result) | |
| get_async_context() | |
| get_feature(feature_type) | |
| get_feature_for_message(feature_type, msg) | |
| get_features(feature_type) | |
| has_feature(feature_type) | |
| pause_message(msg) | |
| prefetch_dns(hostname, cancellable, callback, *user_data) | |
| prepare_for_uri(uri) | |
| queue_message(msg, callback, *user_data) | |
| redirect_message(msg) | |
| remove_feature(feature) | |
| remove_feature_by_type(feature_type) | |
| request(uri_string) | |
| request_http(method, uri_string) | |
| request_http_uri(method, uri) | |
| request_uri(uri) | |
| requeue_message(msg) | |
| send(msg, cancellable) | |
| send_async(msg, cancellable, callback, *user_data) | |
| send_finish(result) | |
| send_message(msg) | |
| steal_connection(msg) | |
| unpause_message(msg) | |
| websocket_connect_async(msg, origin, protocols, cancellable, callback, *user_data) | |
| websocket_connect_finish(result) | |
| would_redirect(msg) | 
Virtual Methods¶
| Inherited: | GObject.Object (7) | 
|---|
| do_auth_required(msg, auth, retrying) | |
| do_authenticate(msg, auth, retrying) | |
| do_cancel_message(msg, status_code) | |
| do_flush_queue() | |
| do_kick() | |
| do_queue_message(msg, callback, *user_data) | |
| do_request_started(msg, socket) | |
| do_requeue_message(msg) | |
| do_send_message(msg) | 
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| accept-language | str | r/w | Accept-Language string | 
| accept-language-auto | bool | r/w | Accept-Language automatic mode | 
| async-context | int | r/w/co | The GLib.MainContextto dispatch async I/O in | 
| http-aliases | [ str] | r/w | URI schemes that are considered aliases for ‘http’ | 
| https-aliases | [ str] | r/w | URI schemes that are considered aliases for ‘https’ | 
| idle-timeout | int | r/w | Connection lifetime when idle | 
| local-address | Soup.Address | r/w/co | Address of local end of socket | 
| max-conns | int | r/w | The maximum number of connections that the session can open at once | 
| max-conns-per-host | int | r/w | The maximum number of connections that the session can open at once to a given host | 
| proxy-resolver | Gio.ProxyResolver | r/w | The Gio.ProxyResolverto use for this session | 
| proxy-uri | Soup.URI | d/r/w | The HTTP Proxy to use for this session deprecated | 
| ssl-ca-file | str | d/r/w | File containing SSL CA certificates deprecated | 
| ssl-strict | bool | r/w | Whether certificate errors should be considered a connection error | 
| ssl-use-system-ca-file | bool | r/w | Use the system certificate database | 
| timeout | int | r/w | Value in seconds to timeout a blocking I/O | 
| tls-database | Gio.TlsDatabase | r/w | TLS database to use | 
| tls-interaction | Gio.TlsInteraction | r/w | TLS interaction to use | 
| use-ntlm | bool | d/r/w | Whether or not to use NTLM authentication deprecated | 
| use-thread-context | bool | r/w | Whether to use thread-default main contexts | 
| user-agent | str | r/w | User-Agent string | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| authenticate | Emitted when the session requires authentication. | 
| connection-created | Emitted when a new connection is created. | 
| request-queued | Emitted when a request is queued on session. | 
| request-started | Emitted just before a request is sent. deprecated | 
| request-unqueued | Emitted when a request is removed from session’s queue, indicating that session is done with it. | 
| tunneling | Emitted when an SSL tunnel is being created on a proxy connection. | 
Class Details¶
- 
class Soup.Session(**kwargs)¶
- Bases: - GObject.Object- Abstract: - No - Structure: - Soup.SessionClass- 
classmethod new()¶
- Returns: - the new session. - Return type: - Soup.Session- Creates a - Soup.Sessionwith 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 a- Soup.SessionAsyncwill have their callback called before- Soup.Session.abort() returns. Requests on a plain- Soup.Sessionwill not.
 - 
add_feature(feature)¶
- Parameters: - feature ( - Soup.SessionFeature) – an object that implements- Soup.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_FEATUREproperty.- See the main - Soup.Sessiondocumentation 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) – a- GObject.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 with- Soup.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.SessionFeaturetype, this gives each existing feature on self the chance to accept feature_type as a “subfeature”. This can be used to add new- Soup.Author- Soup.Requesttypes, for instance.- You can also add a feature to the session at construct time by using the - Soup.SESSION_ADD_FEATURE_BY_TYPEproperty.- See the main - Soup.Sessiondocumentation 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 cancel
- status_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 with- Soup.Session.queue_message() will have their callbacks invoked before- Soup.Session.cancel_message() returns. The plain- Soup.Sessiondoes not have this behavior; cancelling an asynchronous message will merely queue its callback to be run after returning to the main loop.
- msg (
 - 
connect_async(uri, cancellable, progress_callback, callback, *user_data)¶
- Parameters: - uri (Soup.URI) – aSoup.URIto connect to
- cancellable (Gio.CancellableorNone) – aGio.Cancellable
- progress_callback (Soup.SessionConnectProgressCallbackorNone) – aSoup.SessionConnectProgressCallbackwhich will be called for every network event that occurs during the connection.
- callback (Gio.AsyncReadyCallbackorNone) – the callback to invoke when the operation finishes
- user_data (objectorNone) – 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 the- Gio.IOStreamto communicate with the server.- New in version 2.62. 
- uri (
 - 
connect_finish(result)¶
- Parameters: - result ( - Gio.AsyncResult) – the- Gio.AsyncResultpassed to your callback- Raises: - GLib.Error- Returns: - a new - Gio.IOStream, or- Noneon error.- Return type: - Gio.IOStream- Gets the - Gio.IOStreamcreated for the connection to communicate with the server.- New in version 2.62. 
 - 
get_async_context()¶
- Returns: - self’s - GLib.MainContext, which may be- None- Return type: - GLib.MainContextor- None- 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-default- GLib.MainContext, and so is not especially useful.
 - 
get_feature(feature_type)¶
- Parameters: - feature_type ( - GObject.GType) – the- GObject.GTypeof the feature to get- Returns: - a - Soup.SessionFeature, or- None. The feature is owned by self.- Return type: - Soup.SessionFeatureor- None- 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.GTypeof the feature to get
- msg (Soup.Message) – aSoup.Message
 - Returns: - a - Soup.SessionFeature, or- None. 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 return- None, not the second feature.- New in version 2.28. 
- feature_type (
 - 
get_features(feature_type)¶
- Parameters: - feature_type ( - GObject.GType) – the- GObject.GTypeof the class of features to get- Returns: - a list of features. You must free the list, but not its contents - Return type: - [ - Soup.SessionFeature]- 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) – the- GObject.GTypeof the class of features to check for- Returns: - Trueor- False- Return type: - bool- 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 as- Soup.Author- Soup.Request).- New in version 2.42. 
 - 
pause_message(msg)¶
- Parameters: - msg ( - Soup.Message) – a- Soup.Messagecurrently 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.SessionAsyncor using- Soup.Session.queue_message()).
 - 
prefetch_dns(hostname, cancellable, callback, *user_data)¶
- Parameters: - hostname (str) – a hostname to be resolved
- cancellable (Gio.CancellableorNone) – aGio.Cancellableobject, orNone
- callback (Soup.AddressCallbackorNone) – callback to call with the result, orNone
- user_data (objectorNone) – data for callback
 - 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 of- Soup.Status.CANCELLED.- New in version 2.38. 
- hostname (
 - 
prepare_for_uri(uri)¶
- Parameters: - uri ( - Soup.URI) – a- Soup.URIwhich may be required- 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 queue
- callback (Soup.SessionCallbackorNone) – aSoup.SessionCallbackwhich will be called after the message completes or when an unrecoverable error occurs.
- user_data (objectorNone) – a pointer passed to callback.
 - 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 using- Soup.SessionAsyncor- Soup.SessionSync, then the- GLib.MainContextthat is used depends on the settings of- Soup.Session- :async-contextand- Soup.Session- :use-thread-context, and for- Soup.SessionSync, the message will actually be sent and processed in another thread, with only the final callback occurring in the indicated- GLib.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 a- Gio.InputStream.
- msg (
 - 
redirect_message(msg)¶
- Parameters: - msg ( - Soup.Message) – a- Soup.Messagethat has received a 3xx response- Returns: - Trueif a redirection was applied,- Falseif not (eg, because there was no Location header, or it could not be parsed).- Return type: - bool- 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_REDIRECTon a message, but have decided to allow a particular redirection to occur, or if you want to allow a redirection that- Soup.Sessionwill 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) – a- GObject.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_TYPEproperty.- New in version 2.24. 
 - 
request(uri_string)¶
- Parameters: - uri_string ( - str) – a URI, in string form- Raises: - GLib.Error- Returns: - a new - Soup.Request, or- Noneon error.- Return type: - Soup.Request- Creates a - Soup.Requestfor retrieving uri_string.- New in version 2.42. 
 - 
request_http(method, uri_string)¶
- Parameters: - Raises: - Returns: - a new - Soup.RequestHTTP, or- Noneon error.- Return type: - Creates a - Soup.Requestfor retrieving uri_string, which must be an “http” or “https” URI (or another protocol listed in self’s- Soup.Session- :http-aliasesor- Soup.Session- :https-aliases).- New in version 2.42. 
 - 
request_http_uri(method, uri)¶
- Parameters: - Raises: - Returns: - a new - Soup.RequestHTTP, or- Noneon error.- Return type: - Creates a - Soup.Requestfor retrieving uri, which must be an “http” or “https” URI (or another protocol listed in self’s- Soup.Session- :http-aliasesor- Soup.Session- :https-aliases).- New in version 2.42. 
 - 
request_uri(uri)¶
- Parameters: - uri ( - Soup.URI) – a- Soup.URIrepresenting the URI to retrieve- Raises: - GLib.Error- Returns: - a new - Soup.Request, or- Noneon error.- Return type: - Soup.Request- Creates a - Soup.Requestfor 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.CancellableorNone) – aGio.Cancellable
 - Raises: - Returns: - a - Gio.InputStreamfor reading the response body, or- Noneon error.- Return type: - Synchronously sends msg and waits for the beginning of a response. On success, a - Gio.InputStreamwill 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 a- Gio.IOErrorEnum.CANCELLEDerror. 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 a- Soup.Message, but doesn’t return until the response has been completely read.- (Note that this method cannot be called on the deprecated - Soup.SessionAsyncsubclass.)- New in version 2.42. 
- msg (
 - 
send_async(msg, cancellable, callback, *user_data)¶
- Parameters: - msg (Soup.Message) – aSoup.Message
- cancellable (Gio.CancellableorNone) – aGio.Cancellable
- callback (Gio.AsyncReadyCallbackorNone) – the callback to invoke
- user_data (objectorNone) – data for callback
 - 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 a- Gio.InputStreamfor 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 a- Soup.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.SessionSyncsubclass, and can only be called on- Soup.SessionAsyncif you have set the- Soup.Session- :use-thread-contextproperty.)- New in version 2.42. 
- msg (
 - 
send_finish(result)¶
- Parameters: - result ( - Gio.AsyncResult) – the- Gio.AsyncResultpassed to your callback- Raises: - GLib.Error- Returns: - a - Gio.InputStreamfor reading the response body, or- Noneon error.- Return type: - Gio.InputStream- Gets the response to a - Soup.Session.send_async() call and (if successful), returns a- Gio.InputStreamthat 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: - int- 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 a- Gio.InputStream.
 - 
steal_connection(msg)¶
- Parameters: - msg ( - Soup.Message) – the message whose connection is to be stolen- Returns: - the - Gio.IOStreamformerly associated with msg (or- Noneif msg was no longer associated with a connection). No guarantees are made about what kind of- Gio.IOStreamis returned.- Return type: - Gio.IOStream- “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.Messagesignal 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) – a- Soup.Messagecurrently 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.SessionAsyncor using- Soup.Session.queue_message()).
 - 
websocket_connect_async(msg, origin, protocols, cancellable, callback, *user_data)¶
- Parameters: - msg (Soup.Message) –Soup.Messageindicating the WebSocket server to connect to
- origin (strorNone) – origin of the connection
- protocols ([str] orNone) – aNone-terminated array of protocols supported
- cancellable (Gio.CancellableorNone) – aGio.Cancellable
- callback (Gio.AsyncReadyCallbackorNone) – the callback to invoke
- user_data (objectorNone) – data for callback
 - Asynchronously creates a - Soup.WebsocketConnectionto 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 new- Soup.WebsocketConnection. On failure it will return a- GLib.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 return- Soup.WebsocketError.NOT_WEBSOCKET.- New in version 2.50. 
- msg (
 - 
websocket_connect_finish(result)¶
- Parameters: - result ( - Gio.AsyncResult) – the- Gio.AsyncResultpassed to your callback- Raises: - GLib.Error- Returns: - a new - Soup.WebsocketConnection, or- Noneon error.- Return type: - Soup.WebsocketConnection- Gets the - Soup.WebsocketConnectionresponse to a- Soup.Session.websocket_connect_async() call and (if successful), returns a- Soup.WebsocketConnectionthat can be used to communicate with the server.- New in version 2.50. 
 - 
would_redirect(msg)¶
- Parameters: - msg ( - Soup.Message) – a- Soup.Messagethat has response headers- Returns: - whether msg would be redirected - Return type: - bool- Checks if msg contains a response that would cause self to redirect it to a new URL (ignoring msg’s - Soup.MessageFlags.NO_REDIRECTflag, 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) –
 
- msg (
 - 
do_authenticate(msg, auth, retrying) virtual¶
- Parameters: - msg (Soup.Message) –
- auth (Soup.Auth) –
- retrying (bool) –
 
- msg (
 - 
do_cancel_message(msg, status_code) virtual¶
- Parameters: - msg (Soup.Message) – the message to cancel
- status_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 with- Soup.Session.queue_message() will have their callbacks invoked before- Soup.Session.cancel_message() returns. The plain- Soup.Sessiondoes not have this behavior; cancelling an asynchronous message will merely queue its callback to be run after returning to the main loop.
- msg (
 - 
do_flush_queue() virtual¶
 - 
do_kick() virtual¶
 - 
do_queue_message(msg, callback, *user_data) virtual¶
- Parameters: - msg (Soup.Message) – the message to queue
- callback (Soup.SessionCallbackorNone) – aSoup.SessionCallbackwhich will be called after the message completes or when an unrecoverable error occurs.
- user_data (objectorNone) – a pointer passed to callback.
 - 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 using- Soup.SessionAsyncor- Soup.SessionSync, then the- GLib.MainContextthat is used depends on the settings of- Soup.Session- :async-contextand- Soup.Session- :use-thread-context, and for- Soup.SessionSync, the message will actually be sent and processed in another thread, with only the final callback occurring in the indicated- GLib.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 a- Gio.InputStream.
- msg (
 - 
do_request_started(msg, socket) virtual¶
- Parameters: - msg (Soup.Message) –
- socket (Soup.Socket) –
 
- msg (
 - 
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: - int- 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 a- Gio.InputStream.
 
- 
classmethod 
Signal Details¶
- 
Soup.Session.signals.authenticate(session, msg, auth, retrying)¶
- Signal Name: - authenticate- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- msg (Soup.Message) – theSoup.Messagebeing sent
- auth (Soup.Auth) – theSoup.Authto authenticate
- retrying (bool) –Trueif 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 to- True, which will continue until you return without calling- Soup.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 you- GObject.Object.ref() it to make sure it doesn’t get destroyed), and then unpause msg when you are ready for it to continue.
- session (
- 
Soup.Session.signals.connection_created(session, connection)¶
- Signal Name: - connection-created- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- connection (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. 
- session (
- 
Soup.Session.signals.request_queued(session, msg)¶
- Signal Name: - request-queued- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- msg (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.Messagesignals are emitted as the message is processed. If the message is requeued, it will emit- Soup.Message- ::restarted, which will then be followed by another #SoupSession::request_started and another set of- Soup.Messagesignals 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 the- Soup.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 other- Soup.Messagesignals) may be invoked multiple times for a given message.- New in version 2.24. 
- session (
- 
Soup.Session.signals.request_started(session, msg, socket)¶
- Signal Name: - request-started- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- msg (Soup.Message) – the request being sent
- socket (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- ::startinginstead.
- session (
- 
Soup.Session.signals.request_unqueued(session, msg)¶
- Signal Name: - request-unqueued- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- msg (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. 
- session (
- 
Soup.Session.signals.tunneling(session, connection)¶
- Signal Name: - tunneling- Flags: - Parameters: - session (Soup.Session) – The object which received the signal
- connection (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. 
- session (
Property Details¶
- 
Soup.Session.props.accept_language¶
- Name: - accept-language- Type: - str- Default Value: - None- Flags: - READABLE,- WRITABLE- If non- - None, the value to use for the “Accept-Language” header on- Soup.Messages sent from this session.- Setting this will disable - Soup.Session- :accept-language-auto.- New in version 2.30. 
- 
Soup.Session.props.accept_language_auto¶
- Name: - accept-language-auto- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- If - True,- Soup.Sessionwill automatically set the string for the “Accept-Language” header on every- Soup.Messagesent, based on the return value of- GLib.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: - int- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- The - GLib.MainContextthat miscellaneous session-related asynchronous callbacks are invoked on. (Eg, setting- Soup.Session- :idle-timeoutwill add a timeout source on this context.)- For a plain - Soup.Session, this property is always set to the- GLib.MainContextthat is the thread-default at the time the session was created, and cannot be overridden. For the deprecated- Soup.Sessionsubclasses, the default value is- None, meaning to use the global default- GLib.MainContext.- If - Soup.Session- :use-thread-contextis- False, this context will also be used for asynchronous HTTP I/O.
- 
Soup.Session.props.http_aliases¶
- Name: - http-aliases- Type: - [ - str]- Default Value: - []- Flags: - READABLE,- WRITABLE- A - None-terminated array of URI schemes that should be considered to be aliases for “http”. Eg, if this included- "dav", than a URI of- dav://example.com/pathwould be treated identically to- http://example.com/path.- In a plain - Soup.Session, the default value is- None, meaning that only “http” is recognized as meaning “http”. In- Soup.SessionAsyncand- Soup.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¶
- Name: - https-aliases- Type: - [ - str]- Default Value: - []- Flags: - READABLE,- WRITABLE- A comma-delimited list of URI schemes that should be considered to be aliases for “https”. See - Soup.Session- :http-aliasesfor 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¶
- Name: - idle-timeout- Type: - int- Default Value: - 60- Flags: - READABLE,- WRITABLE- 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 using- Soup.SessionAsyncor- Soup.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: - Soup.Address- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- Sets the - Soup.Addressto 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¶
- Name: - max-conns- Type: - int- Default Value: - 10- Flags: - READABLE,- WRITABLE- The maximum number of connections that the session can open at once 
- 
Soup.Session.props.max_conns_per_host¶
- Name: - max-conns-per-host- Type: - int- Default Value: - 2- Flags: - READABLE,- WRITABLE- 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: - Gio.ProxyResolver- Default Value: - None- Flags: - READABLE,- WRITABLE- A - Gio.ProxyResolverto use with this session. Setting this will clear the- Soup.Session- :proxy-uriproperty, and remove any- SoupProxyURIResolverfeatures that have been added to the session.- By default, in a plain - Soup.Session, this is set to the default- Gio.ProxyResolver, but you can set it to- Noneif you don’t want to use proxies, or set it to your own- Gio.ProxyResolverif you want to control what proxies get used.- New in version 2.42. 
- 
Soup.Session.props.proxy_uri¶
- Name: - proxy-uri- Type: - Soup.URI- Default Value: - None- Flags: - DEPRECATED,- READABLE,- WRITABLE- A proxy to use for all http and https requests in this session. Setting this will clear the - Soup.Session- :proxy-resolverproperty, and remove any- SoupProxyURIResolverfeatures that have been added to the session. Setting this property will also cancel all currently pending messages.- Note that - Soup.Sessionwill normally handle looking up the user’s proxy settings for you; you should only use- Soup.Session- :proxy-uriif 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 a- Gio.SimpleProxyResolverand set the- Soup.Session- :proxy-resolverproperty.- Deprecated since version 2.70: Use - Soup.Session- :proxy-resolveralong with- Gio.SimpleProxyResolver.
- 
Soup.Session.props.ssl_ca_file¶
- Name: - ssl-ca-file- Type: - str- Default Value: - None- Flags: - DEPRECATED,- READABLE,- WRITABLE- 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 else- Soup.Session- :tls-databasewith a- Gio.TlsFileDatabase(which allows you to do explicit error handling).
- 
Soup.Session.props.ssl_strict¶
- Name: - ssl-strict- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE- Normally, if - Soup.Session- :tls-databaseis set (including if it was set via- Soup.Session- :ssl-use-system-ca-fileor- Soup.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 the- Soup.Messagewill fail with the status- Soup.Status.SSL_FAILED.- If you set - Soup.Session- :ssl-strictto- False, then all certificates will be accepted, and you will need to call- Soup.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 is- True, then all certificates will be rejected. However, beware that the deprecated- Soup.Sessionsubclasses (- Soup.SessionAsyncand- Soup.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¶
- Name: - ssl-use-system-ca-file- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE- Setting this to - Trueis equivalent to setting- Soup.Session- :tls-databaseto the default system CA database. (and likewise, setting- Soup.Session- :tls-databaseto the default database by hand will cause this property to become- True).- Setting this to - False(when it was previously- True) will clear the- Soup.Session- :tls-databasefield.- See - Soup.Session- :ssl-strictfor more information on how https certificate validation is handled.- Note that the default value of - Trueonly applies to plain- Soup.Sessions. If you are using- Soup.SessionAsyncor- Soup.SessionSync, the default value is- False, for backward compatibility.- New in version 2.38. 
- 
Soup.Session.props.timeout¶
- Name: - timeout- Type: - int- Default Value: - 0- Flags: - READABLE,- WRITABLE- 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 using- Soup.SessionAsyncor- Soup.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: - Gio.TlsDatabase- Default Value: - None- Flags: - READABLE,- WRITABLE- Sets the - Gio.TlsDatabaseto use for validating SSL/TLS certificates.- Note that setting the - Soup.Session- :ssl-ca-fileor- Soup.Session- :ssl-use-system-ca-fileproperty will cause this property to be set to a- Gio.TlsDatabasecorresponding to the indicated file or system default.- See - Soup.Session- :ssl-strictfor more information on how https certificate validation is handled.- If you are using a plain - Soup.Sessionthen- Soup.Session- :ssl-use-system-ca-filewill be- Trueby default, and so this property will be a copy of the system CA database. If you are using- Soup.SessionAsyncor- Soup.SessionSync, this property will be- Noneby default.- New in version 2.38. 
- 
Soup.Session.props.tls_interaction¶
- Name: - tls-interaction- Type: - Gio.TlsInteraction- Default Value: - None- Flags: - READABLE,- WRITABLE- A - Gio.TlsInteractionobject that will be passed on to any- Gio.TlsConnectionscreated 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: - bool- Default Value: - False- Flags: - DEPRECATED,- READABLE,- WRITABLE- 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¶
- Name: - use-thread-context- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- If - True(which it always is on a plain- Soup.Session), asynchronous HTTP requests in this session will run in whatever the thread-default- GLib.MainContextis at the time they are started, rather than always occurring in- Soup.Session- :async-context.- New in version 2.38. 
- 
Soup.Session.props.user_agent¶
- Name: - user-agent- Type: - str- Default Value: - None- Flags: - READABLE,- WRITABLE- If non- - None, the value to use for the “User-Agent” header on- Soup.Messages 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.Sessionwill append its own product token (eg, “- libsoup/2.3.2”) to the end of the header for you.