Soup.ClientContext

Fields

None

Methods

get_address ()

get_auth_domain ()

get_auth_user ()

get_gsocket ()

get_host ()

get_local_address ()

get_remote_address ()

get_socket ()

steal_connection ()

Details

class Soup.ClientContext

A Soup.ClientContext provides additional information about the client making a particular request. In particular, you can use Soup.ClientContext.get_auth_domain() and Soup.ClientContext.get_auth_user() to determine if HTTP authentication was used successfully.

Soup.ClientContext.get_remote_address() and/or Soup.ClientContext.get_host() can be used to get information for logging or debugging purposes. Soup.ClientContext.get_gsocket() may also be of use in some situations (eg, tracking when multiple requests are made on the same connection).

get_address()
Returns:

the Soup.Address associated with the remote end of a connection, it may be None if you used Soup.Server.accept_iostream().

Return type:

Soup.Address or None

Retrieves the Soup.Address associated with the remote end of a connection.

Deprecated since version ???: Use Soup.ClientContext.get_remote_address(), which returns a Gio.SocketAddress.

get_auth_domain()
Returns:

a Soup.AuthDomain, or None if the request was not authenticated.

Return type:

Soup.AuthDomain or None

Checks whether the request associated with self has been authenticated, and if so returns the Soup.AuthDomain that authenticated it.

get_auth_user()
Returns:

the authenticated-as user, or None if the request was not authenticated.

Return type:

str or None

Checks whether the request associated with self has been authenticated, and if so returns the username that the client authenticated as.

get_gsocket()
Returns:

the Gio.Socket that self is associated with, None if you used Soup.Server.accept_iostream().

Return type:

Gio.Socket or None

Retrieves the Gio.Socket that self is associated with.

If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (eg, by using weak references), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.

New in version 2.48.

get_host()
Returns:

the IP address associated with the remote end of a connection, it may be None if you used Soup.Server.accept_iostream().

Return type:

str or None

Retrieves the IP address associated with the remote end of a connection.

get_local_address()
Returns:

the Gio.SocketAddress associated with the local end of a connection, it may be None if you used Soup.Server.accept_iostream().

Return type:

Gio.SocketAddress or None

Retrieves the Gio.SocketAddress associated with the local end of a connection.

New in version 2.48.

get_remote_address()
Returns:

the Gio.SocketAddress associated with the remote end of a connection, it may be None if you used Soup.Server.accept_iostream().

Return type:

Gio.SocketAddress or None

Retrieves the Gio.SocketAddress associated with the remote end of a connection.

New in version 2.48.

get_socket()
Returns:

the Soup.Socket that self is associated with.

Return type:

Soup.Socket

Retrieves the Soup.Socket that self is associated with.

If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (either by using weak references, or by connecting to the Soup.Socket ::disconnected signal), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.

Deprecated since version ???: use Soup.ClientContext.get_gsocket(), which returns a Gio.Socket.

steal_connection()
Returns:

the Gio.IOStream formerly associated with self (or None if self was no longer associated with a connection). No guarantees are made about what kind of Gio.IOStream is returned.

Return type:

Gio.IOStream

“Steals” the HTTP connection associated with self from its Soup.Server. This happens immediately, regardless of the current state of the connection; if the response to the current Soup.Message has not yet finished being sent, then it will be discarded; you can steal the connection from a Soup.Message :wrote-informational or Soup.Message :wrote-body signal handler if you need to wait for part or all of the response to be sent.

Note that when calling this function from C, self will most likely be freed as a side effect.

New in version 2.50.